And the sync function uses ‘channel(doc.channels)’ for database “test”.

Is this the problem? Then how do I assign (existing) documents of a bucket to a channel? I assume this can be done in a view? Or can I assign a channel (property) then the documents are introduced into couchbase (via Java Couchbase Client 2.02 API)?

Don’t do that! The gateway’s bucket is private and should only be modified by Sync Gateway itself. If you want to write to it from your own code, either talk to the gateway’s REST API, or use the bucket shadowing feature to create a separate bucket that you can use Couchbase SDKs to write to.

“The body of the request contains the database configuration as a JSON object ()the same as an entry in the databases property of a configuration file. Note that this doesn’t create a Couchbase Server bucket—you need to do that before configuring the database.”

So, first I need to create the bucket in the couchbase, then configure it via the sync gateway? Can you/someone tell me how?

You’ll probably want to add the database to Sync Gateway by editing its config file. If you do it using a PUT request, the setting isn’t persistent and will need to be redone next time you start the gateway.

Yeah, we don’t have much tutorial documentation of the REST API. That’s partly because it’s nearly identical to the CouchDB REST API, which is already documented pretty well elsewhere. (That isn’t an excuse, and we do plan to add more docs, but at least for this particular doc hole we can point people to external sites like the CouchDB docs and the CouchDB book.)