Read Document in PouchDB

Read Document To retrieve the document created in PouchDB, the db.get() method is used. Syntax: db.get(document, callback) Example: Create a file named “ReadDocument.js” within a folder named “Examples”. Add the below code to the file. ReadDocument.js: var PouchDB = require(’PouchDB’); var db = new PouchDB(’Example_Database’); db.get(’100′, function(err, doc) { if (err) { return console.log(err); } … Read more

Create Document in PouchDB

Create Document To create a document in PouchDB, the db.put() method is used. Syntax: db.put(document, callback) Example: Create a file named “NewDocument.js” within a folder named “Examples”. Add the below code to the file.NewDocument.js: var PouchDB = require(’PouchDB’); var db = new PouchDB(’Example_Database’); doc = { _id: ‘100’, name: ‘Tom’, salary: 45000, experience: 3 } … Read more

Delete Database in PouchDB

PouchDB Delete Database To delete a database in PouchDB, the db.destroy() method is used. Syntax: db.destroy() Example: Open Node.js command prompt. Create a file named “DeleteExample.js” within a folder named “Examples”. Add the below code to the file. DeleteExample.js: var PouchDB = require(’PouchDB’); var db = new PouchDB(’Example_Database’); db.destroy(function (err, response) { if (err) { return … Read more

Database Info in PouchDB

Database Info To get the information about a PouchDB database, the info () method is used in PouchDB. Syntax: db.info([callback]) Example: Create a file named “InfoExample.js” within a folder name “Examples”. Add the below code to the file. InfoExample.js var PouchDB = require(’PouchDB’); var db = new PouchDB(’Example_Database’); db.info(function(err, info) { if (err) { return … Read more

PouchDB Create Database

PouchDB Create Database PouchDB constructor is used in Node.js command prompt to create a database in PouchDB. Syntax: new PouchDB(Database_name) Example: Open Node.js command prompt. Create a file named “Example.js” within a folder named “Examples”. Add the below code to the file.   Example.js: var PouchDB = require(‘PouchDB’); var x = new PouchDB(‘Example_Database’); console.log (“Database … Read more

Install PouchDB

Steps to Install PouchDB Firstly, install Node.js for using PouchDB with Node console. Download and install npm. Install PouchDB by executing the below code on Node.js command prompt. npm install pouchdb Install PouchDB Server by executing the below code on Node.js command prompt. npm install -g pouchdb-server Set a port to run PouchDB: pouchdb-server –port 5000 … Read more