2
votes

We are working on a case much akin to this one (PouchDB: Multiple remote databases, single local database (fancy replication)), and are not sure of what would be the better approach.

To sketch the scenario first, we have multiple 'ordinary users' (which I will refer to as simply 'users' from now on), and a small set of 'super users' (which I will call 'admins' to keep the vocabulary simple).

Users can create documents and edit documents, these documents are uniquely assigned to them. This functionality should be available both online and offline. To realise this, we would just work with one remote seperate CouchDB per user, synced to a PouchDB on the device.

Now, we also have admins, that can view and edit all documents from all users. They can also add a document to the bucket of a user. Realising this functionality is what the question is about.

Right now we identified two possible approaches, and are not sure about which one is the way to go.

Our first solution is to give these admins also a CouchDB, and set-up filtered two-way replication between all users their CouchDBs and the admin his CouchDB. The admin's CouchDB would then sync with a local PouchDB.

The second solution is the one sketched in the link at the top, which is to sync all users their CouchDBs directly to a PouchDB on the admin's device, and to set-up filtered replication in the other direction. We could determine which CouchDBs to sync based on user roles.

The second solution seems simpler and less brittle (less data duplication in the CouchDBs, less replication set-up in CouchDB), but we were not so sure about the performance overhead of opening up a pretty big number of Couch <-> Pouch replications simultaneously.

Does anyone have any experience with cases like this one? Any feedback on what would be the better solution? Or is there another one that we missed? All comments are welcome!

1

1 Answers

1
votes

Have you considered that the data stays only in the users database and that the admin creates a new local database that replicates the User Database?

More detailed I would suggest the admin interface creates the local database for example with a naming schema like "userdb-{$userid}".

You could then do a replication from the users database to the admins local copy.

All changes would be synced to the users database and you don't need any filtered replications and don't risk to mix data of different users.

From the limited knowledge of your exact requirements that could be a better and simpler solution.