Search code examples
androidcouchdbcouchbasecouchbase-lite

Couchbase Lite and CouchDb


I've built an Android app based on Couchbase Lite which talks to a Couchbase Database via Sync Gateway. I've now tried to get Couchbase Lite to replicate with a CouchDB 2.0 database, but I am getting the following error:

W/RemoteRequest: com.couchbase.lite.replicator.RemoteRequest {POST,
http://192.168.1.5:5984/_revs_diff}: Got error status: 404 for
http://192.168.1.5:5984/_revs_diff. Reason: Object Not Found
W/Sync: PusherInternal{http://192.168.1.5:5984, push, 12ff9}: Progress:
set error =com.couchbase.lite.replicator.RemoteRequestResponseException:
Object Not Found

Note that for this I am not going through Sync Gateway but rather point Couchbase Lite directly to the CouchDB Url.

I don't know whether I need to go through Sync Gateway or not, but my impression after reading the Couchbase docs on Couchbase lite is that I do not when connecting to a CouchDb database and this post seems to back that up. https://github.com/couchbase/sync_gateway/issues/312

Can someone please confirm whether it is possible for couchbase lite to replicate directly with a CouchDb 2.0 database and if so what is the correct way to set it up?

Also, the app will be used by many sites, a site can be made up of one or more users. The reason I was thinking switching to CouchDb is so that I can have one database per site, something which doesn't seem to be easily doable in Couchbase. However, I have now discovered Channels in Couchbase which allow me to use one database but keep access to documents restricted by site (i.e. a site could have many users and all users should have access to all documents for that site).

What would be the pros and cons of using either separate databases in CouchDb or channels in Couchbase?

Thanks.


Solution

  • A few points in response:

    The main thing is I think you can do what you want easily in Couchbase. Buckets in Couchbase Server are somewhat equivalent to separate databases. So you could split your sites that way. Channels in Sync Gateway give you more control for separating data and controlling access, as you've seen.

    Couchbase Lite should be able to sync with CouchDB, but this isn't heavily tested. It's hard to tell from your snippet what's going wrong. You might check this post for some ideas: CouchDB: how to use _revs_diff to get document revision ID

    Sync Gateway exposes a sort of superset of the CouchDB replication endpoints, so you'll have more flexibility using Couchbase Lite with Sync Gateway.