PouchDB in Hindi Delete Document




PouchDB डेटाबेस से एक Document को हटाने के लिए DB.remove () Method का उपयोग किया जाता है. Document को हटाने के लिए आपको Id और _rev मान देना होगा.

और यह Method एक Callback function को स्वीकार करता है. आप Id और _rev के जगह में पूर्ण Document भी पास कर सकते हैं.

Syntax

db.remove( doc_Id, doc_Rev, [callback] )  

Example

सबसे पहले एक Document की Value को प्राप्त करें फिर जिसे आप Read Document Method का उपयोग करके जिस Document को Delete करना चाहते हो उसको Delete कर सकते हो.

{ age: 21,  
  _id: '001',  
  _rev: '2-b26971720f274f1ab7234b3a2be93c83' }   

यह Document PouchDB में "Second_Database" नामक Database के रूप मे Store होता है.

अब, _rev value के साथ remove() Method का उपयोग करके और Document की Id को लेते है.

//Requiring the package  
var PouchDB = require('PouchDB');  
//Creating the database object  
var db = new PouchDB('Second_Database');  
//Deleting an existing document  
db.remove('001', '2-b26971720f274f1ab7234b3a2be93c83', function(err) {  
   if (err) {  
      return console.log(err);  
   } else {  
      console.log("Document deleted successfully");  
   }  
});

अब हम एक Folder PouchDB_Examples के Name से बनाते है और उसके "Delete_Document.js नामक File में Code को Save कर लेते है.

node Delete_Document.js