I am having trouble replicating documents using channels. I am testing a case where I have pushed documents through sync gateway. Then I delete the database, or use another device, and try to pull those documents for that user. When I query documents that should have been pulled, I get 0 documents returned. My set up is as follows: each user has a channel in sync gateway. This is assigned when the user registers with the sync gateway. Then, when the pull replication is set up, I set the channels according the the user id.
Push = db.CreatePushReplication(uri);
Pull = db.CreatePullReplication(uri);
var auth = AuthenticatorFactory.CreateBasicAuthenticator(username, password);
Pull.Channels = GetChannels();
Push.Authenticator = auth;
Pull.Authenticator = auth;
Push.Continuous = true;
Pull.Continuous = true;
Push.Changed += OnReplicationChanged;
Pull.Changed += OnReplicationChanged;
Push.Start();
Pull.Start();
where GetChannels is:
protected List<string> GetChannels()
{
var channels = new List<string>
{
"ch_" + _userId,
"public"
};
return channels;
}
Here is an example sync user who has assigned channels:
{
"name": "john3",
"admin_channels": {
"ch_john3": 3
},
"all_channels": {
"!": 1,
"ch_john3": 3
},
"sequence": 3,
"passwordhash_bcrypt": "X",
"rolesSince": {}
}
and a document that has the channels property:
{
"_sync": {
"rev": "1-bf5b7541c1225d705b9603169266d8db",
"sequence": 16,
"recent_sequences": [
16
],
"history": {
"revs": [
"1-bf5b7541c1225d705b9603169266d8db"
],
"parents": [
-1
],
"channels": [
[
"ch_john3"
]
]
},
"channels": {
"ch_john3": null
},
"time_saved": "2016-11-06T04:23:22.241165778Z"
},
"channels": [
"ch_john3"
],
"date": "2016-11-06T12:23:22.476175+08:00"
}
Where am I going wrong?