To replicate a user database using couchdb

I have an application that will contain information that is sensitive to the user. From what I can say, I have to use a database for each user architecture. I would like for each user db (potentially client side) to replicate a database located on a public server, and allow users to access the application from any device so that the user can log into the device, the database will be detected by some middle tier on a shared server and then the replicated client side and the synchronization between the device and the public server.

CouchDB seems to be good for (based on my google search), but are there any examples of applications that execute what I am describing (or close to)? I am using couchdb 1.1.0.

+4
source share
1 answer

Yes, CouchDB sounds very good for this - its simple protocol makes it very suitable for web applications [even offline, see pouchdb ] and mobile / desktop applications [again even offline, see Couchbase Mobile .

Unfortunately, I don’t know because of the large publicly available example of the code level, but the main idea is to use a combination of filtered replication and document validation:

The basic idea is that for your server-side copy of the user database, you have validation features configured to require the required document schemas and access control. The end user receives a replica of this database, which can be used for low latency and offline access - theoretically they can undermine their copy, but if the replication function is replicated, it will prevent damage to the database on the server side.

You can even set up a base database that is not publicly available, then use filtered replication to synchronize each user’s data with the server, side databases for each user — useful for centralized messaging, aggregate statistics that only need to back up one database and etc.

There are several high-level examples in this “New Features in Replication” article , especially “DesktopCouch” and “Need-to-know-based Data Sharing” to use snippets to the end.

UPDATE (2015/03/10) . I no longer recommend using CatchDB filtered replication as described above. There are several performance and scalability issues (if this is not about reliability) that arise when you try to replicate more than a few filtered channels from a central database. You can try Couchbase and Sync Gateway if you need read permissions at the document level or create your own changes for each user (for example, protected by special middleware) using _local_seq .

+8
source

Source: https://habr.com/ru/post/1379640/


All Articles