How should I interact with couchbase.

Hello, I'm developing a 'system' that is available via web browser and android, I'm using couchbase server to store documents in the web application and couchbase mobile with android. To make the sync of these applications I'm using the couchbase sync, but I have a few questions about it.

How should I develop my application?

- Should I use the couchbase lib available for nodejs/android and manage the documents in the 'default' bucket and then use the shadow feature of couchbase sync to replicate?

- Should I use the couchbase sync REST API to manage my documents and store them using the sync bucket as the main (and only) bucket?

- Should I use the sync bucket as the main bucket and manage the documents via the couchbase lib (node/android) instead of the REST API?

- Does the couchbase lib (node/android) works well with a sync bucket or it's better to use the API?

I'm really at a loss here.

1 Answer

« Back to question.

Your two options are
(a) Write your web-app using the Sync Gateway REST API to interact with the database;
or
(b) Use the bucket-shadowing feature and have your web-app operate on the main bucket, while the Gateway uses the shadow of that bucket to sync with clients.

Option (a) will use fewer resources, since bucket shadowing creates duplicate copies of the data. But option (b) may be more attractive to developers who are already familiar with the Couchbase Server APIs and want to use those.

--Jens

First of all, thanks for your reply.

I have a problem with the A option, when I try to use the Sync Gateway REST API from AngularJS, I receive a CORS error. Is there any option that I can put into the config of the Sync Gateway to ignore CORS?

Ah, I was talking about accessing the Sync Gateway API from server-side code, not directly from a browser.

The Gateway doesn't yet have CORS support, but I know there's an issue filed in the tracker on Github requesting it.

Thanks.