Running multiple db on Android with sync gateway


#1

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?


#2

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


#3

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


#4

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


#5

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


#6

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