Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syncing PouchDB offline to PostgreSQL

I am trying to make my web application work on offline mode by using pouchDB. but the backend database server i used is PostgreSQL (NoSQL). I couldn't find a way to Sync my PouchDB data to postgreSQL when my app came back to online. Can anyone please give me an idea how to do it

like image 771
isc Avatar asked Jul 14 '16 10:07

isc


People also ask

Where is PouchDB data stored?

In PouchDB, when the application is offline, the data is stored locally using WebSQL and IndexedDB in the browser. When the application is back online, it is synchronized with CouchDB and compatible servers.

How does PouchDB store data?

It stores data locally using IndexedDB and WebSQL in the browser. You can also communicate with remote and local databases continuously using PouchDB without noticing any difference. It is available on GitHub and on other open source application.

Is PouchDB a NoSQL?

PouchDB is an open-source, NoSQL, in-line database. It is designed after CouchDB, which is a NoSQL database that powers npm.


1 Answers

Short answer: You can't. It's impossible. Give up. You need CouchDB.

Long answer: You have two options:

  1. you can implement a custom replicator for PouchDB (it is just a PouchDB plugin -- that can get complicated, but not necessarily --, see the default Pouch-Couch replicator source code); or
  2. you can set up a backend service that acts as a proxy between PouchDB and Postgres, that will basically require you to understand and implement the CouchDB replication protocol, i.e., you'll need a server with a bunch of HTTP endpoints that return exactly what the PouchDB replicator expects.

See also this answer from another question.

like image 176
fiatjaf Avatar answered Oct 11 '22 03:10

fiatjaf