4
votes

I have been reading docs and articles on pouchdb/couchdb/cloudant. I am not able to create this simple architecture in my head. I need help!

So there are many users on the app. Each user has a separate database (which I read is the approach in pouch/couch/cloudant setup).

  • Now lets just focus on a single user. This user has some remote data already present on our server(couchdb). He has 3 separate docs stored.
  • He accesses docs 1 and docs 2 from browser 1. And docs 2 and docs 3 from browser 2.
  • Content in both the browsers must be in sync.

Simple design in pouchdb

  1. Should I be using Sync api of pouchdb? But as I read, it sync's the whole database. How can I use this api to sync only a subset of the central database. Is filtered replication answer here?

  2. And also I don't want to push both the docs in a single call. He can access docs as he needs.

  3. What is the correct approach to implement this logic with pouch/couch databases. If you can explain with a little code, that will be great. I just need basic ideas.

  4. Is this kind of problem easily solvable in upcoming releases of CouchDB 2.0 and PouchDB-find.

Thanks a lot!

1

1 Answers

6
votes

If you take a look at the PouchDB documentation, you should see the options.doc_ids. This parameter let you setup a replication on certain document ids. In your scenario, this would be solving your problem.