This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| ok: true, | |
| id: "002", | |
| rev: "4-d6f058da696f4760b31492c9f00ad1ec" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let PouchDB = require('pouchdb'); //require the package | |
| let db = new PouchDB('test_db222'); | |
| //created the db | |
| console.log ("Database created Successfully."); | |
| //get the doc | |
| db.get('002').then(function (doc) { | |
| // remove the doc | |
| return db.remove(doc._id, doc._rev); | |
| }).then(function(err,info){ | |
| //print the data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {name: "Karthi", age: 40, designation: "Designer", _id: "002", _rev: "3-9a7dac1a7b1a4332b9d44d9dd5dca757"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let PouchDB = require('pouchdb'); | |
| let db = new PouchDB('test_db222'); | |
| //creating the db | |
| console.log ("Database created Successfully."); | |
| //get the data and update | |
| db.get('002').then(function (doc) { | |
| // update their age | |
| doc.age = 40; | |
| // put them back | |
| return db.put(doc); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {name: "Karthi", age: 23, designation: "Designer", _id: "002", _rev: "1-38fd304f70974adeb370e3cf8bc89f39"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let PouchDB = require('pouchdb'); | |
| let db = new PouchDB('test_db222'); | |
| //success message | |
| console.log ("Database created Successfully."); | |
| //getting the document from the database | |
| db.get('002',(err,info)=>{ | |
| if(!err){ | |
| console.log("db value",info) | |
| } | |
| else{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //CustomPouchError | |
| { | |
| status: 409, | |
| name: "conflict", | |
| message: "Document update conflict", | |
| error: true, | |
| id: "003" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Document created Successfully | |
| {ok: true, id: "003", rev: "1-325eb8a7f91c4035a033fca9f5c32f52"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let PouchDB = require('pouchdb'); | |
| let db = new PouchDB('test_db222'); | |
| console.log ("Database created Successfully."); | |
| //creating a new database | |
| //Preparing the document | |
| let doc = { | |
| _id : '002', | |
| name: 'Karthi', | |
| age : 23, | |
| designation : 'Designer' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Requiring the package | |
| var PouchDB = require('PouchDB'); | |
| //Creating the database object | |
| var db = new PouchDB('test_db222'); | |
| //deleting database | |
| db.destroy(function (err, response) { | |
| if (err) { | |
| return console.log(err); |