Couchbase Lite Channels Problem


#1

Hi There,
Im doing an application for multiple users. So Im trying to use Channels feature.

Here im using Many to Many Channels concept. For example i have following channels likes

1 ChannelX1 contents following sub channels.
i) ChannelY1, ii) ChannelY2, … soon

2 ChannelX2 contents following sub channels.
i) ChannelZ1, ii) ChannelZ2, … soon

3 ChannelX3 contents following sub channels.
i) ChannelA1, ii) ChannelA2, … soon

So now i want replicate only [ ChannelX1, ChannelY1] data but im getting ChannelY2 data also because of couchbase Channels (Documents that do not belong to any of the specified channels are ignored (even if the user has access to them).)

So how can i achieve only above issue and separate number of channel and sub channel data from replications.


#2

@itssrinadh

By default a Couchbase Lite Client will pul documents from all the channels an authenticated user has access to.

If you want to limit the channels that documents are pulled from, you will need to pass the list of channels the replications will use.

using curl, this is what the request would look like for a one shot replication.

curl -X POST http://foo:foo@localhost:4984/db/_changes -H "Content-Type: application/json" -d '{"filter":"sync_gateway/bychannel","channels":"ChannelX1,ChannelY1"}'

You could use this curl command against your Sync Gateway to see if it filters the documents in the way that you want.


#3

@andy Hey how can i do this on iOS app side. instead of synch gateway server.


#4

Just a point of clarification on your original post - there’s no concept of hierarchy within channels themselves. You can manage access to sets of channels using roles, but there’s no subchannel concept.

Here’s the client documentation on setting up a filtered pull replication:
http://developer.couchbase.com/documentation/mobile/1.2/develop/guides/couchbase-lite/native-api/replication/index.html#filtered_pull