Running multiple db on Android with sync gateway

Hello guys, I would like to ask if it is possible to use multiple database for a single data bucket and sync gateway setup?

My idea would be to store all user created accounts on a ‘user’ database and sync. And each user had a purchase details which I think should be stored on a ‘purchase’ db. I don’t know if this is recommended or should I just setup a single database that will store uses and purchase details?

One database corresponds to one bucket. It doesn’t sound like there’s any reason to use two databases for this scenario.

1 Like

Thank you for the reply.
Does this mean in one application, I can only run 1 sync gateway instance?

If I will be using 1 db, the structure would be:

myDb:
    "user1":{ // whenever user will be added,
        "username": "myUsername",
        "password": "myPassword",
        "purchase":{
           //purchase properties here...
           // this will be synced every time a new purchase or etc.
        },
    },
    "user2":{
        "username": "myUsername",
        "password": "myPassword",
        "purchase":{
           //purchase properties here...
           // this will be synced every time a new purchase or etc.
        },
    }

Is this a good structure? are there any suggestion for this? I’m still learning this technology.
Thanks

I think what you really want to look at are Channels http://docs.couchbase.com/sync-gateway/#authorizing-users

1 Like

I already understood this recently. :smile:
@KillerTofu Is this the same with using persona or facebook login?

I’m not sure to be honest. I’m not using either of those login methods in my project.

Hi Jens,

I have related question about this.

Is it possible to sync from multiple buckets in 1 app and sync gateway config?

Yes. But we call them “databases” in Couchbase Lite, not “buckets”.