0
votes

I'm using PouchDB + CouchDB to store and sync data in an angular app currently in development. Data is stored per user and contains things such as user authorities/settings, recently viewed content and cart items.

Currently, I have a single CouchDB database that contains a doc for each user. While this structure works well for quickly retrieving user-specific data, it's logically flawed because all user docs are synced to any device that accesses the app. In other words, I ultimately only need the currently logged in user's data to sync.

So, my question is, should I create a Couch database for each user instead of using a single database with a doc for each user? Or is there a better way to go about this?

1
Have you tried setting a pull filter? - Hypnic Jerk
@MichaelPickett No I haven't, can you point me to an example or docs? Is a pull filter accomplished with design doc queries? - Jbird
Heres something I found that may help pouchdb.com/2015/04/05/filtered-replication.html - Hypnic Jerk
@MichaelPickett Damn...how did I not find that. That looks to be a very helpful article. Just in the first few lines he mentions, "There's no shame in creating a DB per user or DB per role!". I feel better already ;) Thank you sir! - Jbird

1 Answers

0
votes

If you look at the pouchdb-authentication plugin you'll see that you can store metadata for a user in the _user database. That might be all you need.