Reputation: 7488
I've stared to build a service with CouchDB. The app is designed for users to have unlimited buckets for several reasons and it worked perfectly. Now i've switched to Couchbase because of some enterprise features. I'm using PouchDB that's why I need Sync Gateway. Sadly I can only map one bucket/database.
This would be a perfect solution for me: /db/bucket/etc
Any ideas how to achieve this?
Upvotes: 0
Views: 1518
Reputation: 1144
A Couchbase Server bucket can hold any arbitrary data. To Sync Gateway, the Couchbase Server bucket is only the storage engine destination and has nothing to do with users and data access. In the Sync Gateway config file, you can list multiple databases persisting to different buckets:
{
"databases":{
"db1": {
"server": "http://localhost:8091",
"bucket": "db1bucket"
},
"db2": {
"server": "http://101.88.47.22:8091",
"bucket": "db2bucket"
}
}
}
Now, let's assume that you declare only one database in the config file and wish to have users get access to certain documents. You can use one of the authentication methods and then based on that write a Sync Function which will route documents in channels and grant users access to those channels. Channels are created on the fly and there's no limit to how many can be created. If you don't wish to use user authentication to access documents in a channel you can specify channel names to the replicator on the client side (which is simpler).
The recommended approach is to use one Sync Gateway database per project or application as opposed to per user. So you may have to migrate the documents from the different CouchDB databases into one Sync Gateway database.
Upvotes: 5