Skip to content

Instantly share code, notes, and snippets.

View skarthikeyan96's full-sized avatar
😎

Karthikeyan skarthikeyan96

😎
  • India
View GitHub Profile
{
ok: true,
id: "002",
rev: "4-d6f058da696f4760b31492c9f00ad1ec"
}
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
{name: "Karthi", age: 40, designation: "Designer", _id: "002", _rev: "3-9a7dac1a7b1a4332b9d44d9dd5dca757"}
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);
{name: "Karthi", age: 23, designation: "Designer", _id: "002", _rev: "1-38fd304f70974adeb370e3cf8bc89f39"}
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{
//CustomPouchError 
{
status: 409,
name: "conflict",
message: "Document update conflict",
error: true,
id: "003"
}
//Document created Successfully
{ok: true, id: "003", rev: "1-325eb8a7f91c4035a033fca9f5c32f52"}
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'
//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);