Hello,
I’ve updated the version of Sync Gateway from 2.0.0 to 3.1.5. I am using couch database version 7.6.1.
The current issue I’m encountering is the inability to utilize the sync function (which is responsible for creating channels) as we did in the previous version of Sync Gateway.
Here’s the database config we used in the older version:
{
“log”: [“HTTP+”],
“adminInterface”: “127.0.0.1:4985”,
“interface”: “0.0.0.0:4984”,
“databases”: {
“database_name”: {
“server”: “serverUrl”,
“bucket”: “bucket_name”,
“username”: “username”,
“password”: “password”,
“enable_shared_bucket_access”: true,
“import_docs”: “continuous”,
“revs_limit”: 20,
“users”: {
“GUEST”: {
“disabled”: true,
“admin_channels”: [“*”]
},
},
“sync”: function(doc){** ** if(doc.Type==2 && doc.id)** ** channel("name_"+doc.id);** ** }
}
}
}
While exploring, I’ve come to understand that we can utilize scopes in the new version to employ the sync function similarly to how we did in the previous version. Here’s the scope we utilized:
“scopes”: {
“scope1”: {
“collections”: {
“collection1”: {
“sync”: "function(doc, oldDoc, meta) { if (doc.type != ‘default’) { throw({forbidden : ‘Rejected document’}) } channel(‘legacy’) } ",
“import_filter”: " function(doc) { return doc.type == ‘mobile’ } "
}
}
}
}
Our updated database config will be like,
{
“disable_persistent_config”: false,
“api”:{
“admin_interface”: “127.0.0.1:4985”,
“admin_interface_authentication”: true,
“profile_interface”: “0.0.0.0:4984”,
“public_interface”: “0.0.0.0:4984”,
},
“bootstrap”: {
“server”: “serverName”,
“server_tls_skip_verify”: true,
“use_tls_server”: false,
“username”: “username”,
“password”: “password”
},
“bucket_credentials”: {
“eacts_membership_2019_01” : {
“password”: “password”,
“username”: “username”,
}
},
“couchbase_keepalive_interval”: 0,
“database_credentials”: {
“eacts_membership_2019_01”: {
“password”: “password”,
“username”: “username”,
}
}
}
However, we’re unsure where to include the scope in the new database config file and how to use it for channel creation.
It would be greatly appreciated if you could provide an example config file demonstrating how to use the sync function to create channels in the new version of Sync Gateway (3.1.5).
Thanks,
Srividhya