CouchDB - Does synchronization copy a database to all users? CouchDB - Does synchronization copy a database to all users? database database

CouchDB - Does synchronization copy a database to all users?


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

  • Cloudant Envoy which stores all the users' data in a single server-side database, but separates each user by manipulation of the the _id field
  • Spiegel which uses "one database per user" and a replication agent that manages the movement of "per user" data into an additional database, for reporting purposes.