alokraop
alokraop

Reputation: 867

Is there a way to sync between two pouchdb instances?

I'm trying to build a topology which consists of the following:

The desktops will only have connectivity to the Internet intermittently, so both the native applications, and the web app need to have separate data stores which sync when online.

For this I found couchdb which seems to be the perfect candidate. I'm building the desktop application on Electron, so I'm thinking of using pouchdb with it and syncing it with couchdb on the server server when online.

The problem though, is that these 2 desktops running Electron apps with pouchdb will need to sync with each other over LAN. Does pouchdb provide the capability to sync with a remote pouchdb? I only see documentation for syncing pouch and couch.

https://pouchdb.com/guides/databases.html

I'm really new to the concept of synchronizing between databases. Dunno if I'm asking something obvious (or obviously impossible). Appreciate the help.

Upvotes: 2

Views: 2033

Answers (1)

nlawson
nlawson

Reputation: 11620

If you want to sync p2p over arbitrary data channels, you may want to look at this plugin: https://github.com/nolanlawson/pouchdb-replication-stream

In your case, though, since you're writing a native app, the dead-easiest way to do this is to use express-pouchdb to sync between the two desktop apps. Here is a video showing how this can be done: https://www.youtube.com/watch?v=5iTzm8sTtd4

Any two PouchDB objects can sync with one another; so as long as you have working PouchDB objects you can sync them with db1.sync(db2).

Upvotes: 5

Related Questions