I was looking for various information on Pouchdb on the Internet and I liked the idea of synchronizing remote databases with local browser database. The first question that came to my mind is whether it stores a whole database on each device and creates copies on each device? Imagine that I'm creating a chat application and all communications will be stored on all devices using this app. One user can then look into the conversation of others. I looked at the Pouchdb documentation and found filtered replication. Could anybody explain how this synchronization works and whether it is possible to synchronize data only to a particular user?
Example:
Here is a remote database e.g. in cloud, where are saved all informations.
Remote database:
/ user / secret informations /
/ Joe / "secret information" /
/ Dan / "secret info again" /
Here i want to synchronize data only for a particular user. Do not sync whole database but only user specific data.
Joe's device
/ user / secret informations /
/ Joe / "secret information" /
Dan's device
/ user / secret informations /
/ Dan / "secret info again" /
I believe I explained my question. Thanks for the anwers.
PouchDB can be used in a many different configurations but a common pattern is to have a PouchDB database in a web browser syncing to a remote Apache CouchDB or Cloudant database.
Because the permissions model for Apache CouchDB is "per database" (i.e. you have read/write/admin access on a whole database or not, there is not currently "per document" access control) the mobile PouchDB database synchronises to a cloud "per user" database. That is, if your app has 10,000 users, it would have 10,000 PouchDB databases on each users' individual browsers and 10,000 CouchDB databases on the server side.
This "one database per user" approach is adopted by frameworks such as Hood.ie - it neatly keeps each user's data separate from each others. The drawback is that it is very difficult to query the entire data set as a whole - continuous replication from the "per user" databases to a central database doesn't scale well.
Other solution in this space are
_id
fieldIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With