Need assistance to pull document from couchbase sever to couchbase lite

Hi there ,

I have an use case as below :

1)I have some pre-defined document on couchbase server as below :

{
“createdDate”: null,
“updatedBy”: null,
“channels”: [
“PSYCHOLOGY-1467SC1”
],
“createdBy”: null,
“docType”: “extensions”,
“docId”: “PSYCHOLOGY-1467SC1extensions”,
.
.
.
.

}

I am using couchbase mobile at the devices on ANDROID and IOS on the startup time I want to pull these data in couchbase mobile on the basis of channels defined in the above document using the Replication in PULL direction but its not working my pulll code looks like .

Replication pull = new Replication(getDatabase(), createSyncURL(), Direction.PULL);
pull.setFilter(“sync_gateway/bychannel”);
pull.setChannels(channels);
pull.setContinuous(true);
pull.start();

But its not working Please help if its possible to pull document from couchbase server to couchbase lite on the basis of any filter of channel.

Hi @gyandubey.deepak,

Yes, this is a core feature. Most likely where you’re running into trouble is creating the document in Couchbase Server directly.

The Couchbase Mobile stack requires extra metadata to handle revision conflicts that Server doesn’t need. Currently putting a document directly into Server doesn’t add this metadata, so Sync Gateway/Couchbase Lite won’t replicate it.

The recommended approach is to run everything through Sync Gateway. So, you’d create the initial docs by writing to Sync Gateway directly. This would be true of all writes to the database.

You can read from CB Server directly. That won’t interfere with anything.

By the way, sorry for the slow response. In the future, please be sure to post questions to a specific category. Otherwise it’s easy to overlook them. Anything mobile related (even if it seems like a server question) it’s usually best to post under the mobile category first. If it’s really a server issue, someone will redirect the question.