Is there possibility to have two databases for one bucket in sync gateway?


#1

This might sound little weird, I am trying to create two databases in SGW which access same database. Reason being at mobile we would like to share same session token for two logical database. We don’t wanna create two set of same users and maintain two sessions.

“databases”: {

	"db1" :{
		"bucket":"TESTBUCKET",
		"server": "http://localhost:8091",
		"username": "xxxxxxx",
		"enable_shared_bucket_access": true,
		"import_docs": "continuous",
		"password": "xxxxxxxx",
		"users":{
		  "GUEST": {"disabled": true, "admin_channels": ["*"] }
			},
		"sync": `function sync(doc, oldDoc) {
					if(oldDoc == null){
						// some logic here
				}`,
                   import_filter" : `function(doc)
				{
                                       // only certain types to imported
				}`,
		}
	},
	"db2" :{
		"bucket":"TESTBUCKET",
		"server": "http://localhost:8091",
		"username": "xxxxx",
		"enable_shared_bucket_access": true,
		"import_docs": "continuous",
		"password": "xxxxxx",
		"users":{
		  "GUEST": {"disabled": true, "admin_channels": ["*"] }
			},
		"sync": `function sync(doc, oldDoc) {
				// some different logic
				}`,
		"import_filter" : `function(doc)
				{
                                       // only certain types to imported
				}`
}

#2

Nope, that’s not a supported config.

The recommended way to do this is to use a single SG database, connected to a single Couchbase Server bucket, and use channels to partition the dataset so that users/roles only see the subset they have access to.

If you can provide more details on your use case, maybe a diagram or something … I can try to provide more insight.


Is it possibility to have two databases for one bucket in sync gateway?