1) What is PouchDB?
PouchDB is an
in-browser database that allows applications to save data. It is an open source database. It runs in
Node.js.
2) In which language PouchDB was written?
PouchDB was written in
JavaScript language.
3) What are the features of PouchDB?
There are following features of PouchDB:
- It is cross browser.
- It is light weight.
- It is easy to learn.
- It is open source etc.
4) How PouchDB does work?
PouchDB does work in two ways:
- Offline: When the application is offline the data is stored locally by using WebSQL and indexedDB.
- Online: When the application is online then, the data is synchronized with CouchDB and compatible server.
5) What are the browsers supported by PouchDB?
There are following browsers supported by PochDB:
Firefox 29+ (Including Firefox OS and Firefox for Android)
Chrome 30+
Safari 5+
Internet Explorer 10+
Opera 21+
Android 4.0+
iOS 7.1+
Windows Phone 8+
6) Which file is used while installing PouchDB?
PouchDB used
.JS file while installing.
script src = "PouchDB-5.3.0.min.js"></script>
7) How can we create a database in PouchDB?
We can create a database in PouchDB by using PouchDB constructor.
Syntax:
new PouchDB(Database_name)
8) Which method is used while using PouchDB package?
PouchDB used
require() method.
Example
//Requiring the package
var PouchDB = require('PouchDB');
9) How can we create database in PouchDB?
We can create database in PouchDB by using following code:
//Requiring the package
var PouchDB = require('PouchDB');
//Creating the database object
var db = new PouchDB('my_database');
console.log ("Database created Successfully.");
10) How can we get basic information about the database?
We can get basic information about the database by using info() method.
11) Which method is used to create document in PouchDB?
In PouchDB,
db.put() method is used to create document.
Syntax:
db.put(document, callback)
12) How can we create an array (batch) of documents in PouchDB?
We can create an array(batch) of documents in PouchDB by using
db.bulkDocks() method.
Example:
//Requiring the package
var PouchDB = require('PouchDB');
//Creating the database object
var db = new PouchDB('my_database');
//Preparing the documents array
doc1 = {_id: '001', name: 'Ram', age: 23, Designation: 'Programmer'}
doc2 = {_id: '002', name: 'Robert', age: 24, Designation: 'Programmer'}
doc3 = {_id: '003', name: 'Rahim', age: 25, Designation: 'Programmer'}
docs = [doc1, doc2, doc3]
//Inserting Documents
db.bulkDocs(docs, function(err, response) {
if (err) {
return console.log(err);
} else {
console.log("Documents created Successfully");
}
});
13) What is the use of Replication?
Replication is used to make a copy of the database.
14) How can we replicate localDB to CouchDB?
We can replicate localDB to CouchDB by using following an example:
//Requiring the package
var PouchDB = require('PouchDB');
var localdb = 'sample_database';
//Creating remote database object
var remotedb = 'http://localhost:5984/sample_database';
//Replicating a local database to Remote
PouchDB.replicate(localDB, remoteDB);
console.log ("Database replicated successfully");
15) What are the PouchDB document methods?
PouchDB document methods are:
db.put()
db.get()
db.remove()