Replication is one of the most important features of PouchDB, i.e. you can make a copy of a database. Either a PouchDB instance stored locally or a CouchDB instance stored remotely can be replicated.
The syntax of replicating a database in PouchDB is given below. Here, a copy of the source database is the target. In this method, the location of source and destination databases can be directly passed in String format, or you can pass objects representing them.
The source and targets can be either PouchDB instances or CouchDB instances.
Suppose there is a database with the name sample_database in PouchDB, and it contains 3 documents doc1, doc2, and doc3, having contents as shown below.
An example which makes a copy of the database named sample_database that is stored locally in CouchDB is given below.
With this a copy of the database named sample_database is made in CouchDB instance and a message is displayed on the console as shown below.
You can verify whether the database is replicated in your CouchDB instance by clicking the following link http://127.0.0.1:5984/_utils/index.html.
On clicking, the list of databases in your CouchDB can be seen. It can also be observed that a copy of the database sample_database is created here.
If you select the replicated database, its contents can be viewed as shown below.
Suppose there is a database with the name Remote_Database in CouchDB and it contains 3 documents, doc1, doc2, and doc3, having contents as shown below.
An example to make a copy of the database named Remote_Database that is stored in CouchDB in the local storage is given below.
With this makes a copy of the database named remote_database in PouchDB instance is made and a message is displayed on the console as shown below.
By executing the code given below, you can verify whether the database is replicated in your Pouch instance or not .
If the database is replicated on executing the above code, you will get the contents of the replicated database as shown below.
PouchDB Related Interview Questions
|Java Script Interview Questions||Adv Java Interview Questions|
|Core Java Interview Questions||CorelDRAW Interview Questions|
|Angular JS Interview Questions||MYSQL DBA Interview Questions|
|NoSQL Interview Questions||CouchDB Interview Questions|
|MongoDB Interview Questions||Advanced C++ Interview Questions|
|Basic C Interview Questions||Stored Procedures Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.