Using Couchbase counters with Sync Gateway

How can I generate numbers for use with Sync Gatway. When I try to use the counter function in Couchbase Server I see:
json: cannot unmarshal number into Go value of type db.documentRoot – db.(*changeCache).DocChanged.func1() at change_cache.go:327

I want to create iBeacon major and minor numbers and need counter.

@bfwarner What are you building? Are you going through SG directly, or using Couchbase Lite?

You can work through Couchbase Server, but we don’t actually recommend it if you’re using Sync Gateway. It’s better to have everything pass through Sync Gateway instead of trying to mix access.

With that in mind, it sounds like you’re trying to build custom doc ids. Any approach you want to take that makes the ids unique will work. If you have some more details we might be able to give a specific suggestion.


I have a custom authentication scheme, I make a profile object of each sync gateway account that gets created. Each profile needs to contain two unique 16 bit numbers, how can I do this through the sync gateway restful api. It doesn’t support CAS.

You can create another bucket on the server and use it to store and generate these numbers. Just don’t touch the bucket Sync Gateway is using.