pouchdb

Sync with multiple databases


How do you use sync in case there are 10 databases.

Do I have to set up 10 new sync?

db = new PouchDB(this.database);

db.sync(remoteCouch, opts1)
db.sync(remoteCouch, opts2)
...

Which means it will open 10 different http connections?


Solution

  • Yes, it does. In that case, you may want to avoid using live replication so you don't keep 10 HTTP connections open. (I.e. just replicate one-at-a-time.)

    Or you can replicate from the 10 PouchDBs to a single in-memory PouchDB and then replicate from that to CouchDB (if your databases can fit in memory).