Reputation: 797
having a bit of trouble finding the correct way to model per user data in couchbase and sync up via couchbase mobile for user specific data. In couchdb you have a separate database per user. What is the best approach in couchbase ?
Upvotes: 3
Views: 297
Reputation: 1242
You can create your documents in that way which can able to ease the retrieve all related entity. e.g.
user_{Guid}
consider Guid
as your UserIDGuid
like credential_{Guid}
so when user logged in we can have userID in session and get all information of that user.Upvotes: 1
Reputation: 2848
In Couchbase there is no such thing as "user data". Its generic and open for your designs.
Normally when you design your object domain model for Couchbase you would inject metadata in your key structure.
For example: Key for Account: "Acc#123456789" - where prefix "Acc#" is telling about type of the key, and "123456789" adds particular address instance of this key...resulting in the unique key. Similarly if you want to encode associated address to the account, you'd architect the following key: "Acc#123456789#Addr" - where postfix "#Addr" identifies type of the key for address object
Now, if you want to have user specific keys, you just simply inject user identifier into the key value (from the example above):
Read more on Couchbase data modeling here and keys and metadata
Upvotes: 1