Filtered pull notification in Phonegap

Hello.

We are replicating specific channels in Android with the next code:

URL url = new URL(“https://example.com/mydatabase/”);
db.createPullReplication(url);
List channels = new ArrayList();
channels.add(“sales”);
channels.add(“inventory”);
pull.setChannels(channels);

Everything works fine, we acan do specific push and pull replications trough specific channels.

We want to do the same on Phonegap, but the REST API documentation does not mention how to set specific channels to replicate.

http://developer.couchbase.com/documentation/mobile/1.1.0/develop/references/couchbase-lite/rest-api/server/post-replicate/index.html

Can you give us some instructions to replicate specific channels in Phonegap?

I think that under the hood, CBL uses a channels parameter in the url to specify a particular channel to pull from.

I don’t know if the _replicate endpoint on the Listener API has a params field in the JSON that would make it possible to specify this (I know there’s one for headers but not sure about the query string).
@jens Is there a field in the JSON to do this from the Listener API?

James

Hello @jamiltz and @jens

I found a Google Groups (Pull filter / Unknown filter) reference to filtered replication in phonegap , but it seems like an old or missed reference in actual documentation. Can you confirm we can still use such method in Couchbase Lite and Sync Server 1.1.0?

In the REST API, use a filter parameter with value sync_gateway/bychannel, and a channels parameter whose value is the channel names separated by commas.

(The channels property in the native API is actually just a shortcut that does exactly this under the hood.)

Hi is this still the way to go with couchbase lite 2.0?
Following the tutorial on https://blog.couchbase.com/data-synchronization-with-couchbase-in-ionic-2-hybrid-mobile-apps/
it says to replicate the following way:
this.database.sync(“http://192.168.57.1:4984/example”, true);
I use sync gateway 1.5 and couchbase lite 2.0 via the Couchbase-Lite-PhoneGap-Plugin
My docs all have a “channels” property with a list of channels.

How do i only sync specific channels?

also see https://github.com/couchbaselabs/cordova-couchbase/issues/1

I have responded to your other post on this topic