PouchDB Replication
PouchDB Replication
- Replication means make a copy of a database. We can replicate either a CouchDB instance stored remotely or a PouchDB instance stored locally.
Syntax
Replicating PouchDB (Local) to CouchDB
- Let's take a database named "sample_database" in PouchDB which have 3 documents doc1, doc2, and doc3, having following content.
Read Also
- Now create a replication of this database in CouchDB:
Save the file name as "Remote_Replication.js" within a folder name "PouchDB_Examples". Open the command prompt and execute the javascript file using node.
Output
PouchDB Replication
Verification
- You can open CouchDB link and see that a database "sample_database" is created.
PouchDB Replication
PouchDB Replication
PouchDB Replication
PouchDB Replication
Replicate CouchDB to PouchDB
- Let's create a database named "remote_database" on CouchDB server with three documents doc1, doc2, and doc3, having contents as following:
PouchDB Replication
- Let's replicate this database in local server PouchDB.
Save the file name as "Local_Replication.js" within a folder name "PouchDB_Examples". Open the command prompt and execute the javascript file using node.
Read Also
Output:
PouchDB Replication
- You can verify if the database is replicated in your Pouch instance by using the following code.
- .Open the command prompt and execute the JavaScript file using node:
Output
PouchDB Replication