PouchDB में एक Document (_rev) का उपयोग करके अपडेट किया जा सकता है. जब हम PouchDB में कोई document बनाते हैं तो एक _rev उत्पन्न होता है.
इसे revision मार्कर कहा जाता है _rev का मान एक Unique Random संख्या है. जब भी हम Document में परिवर्तन करते हैं तो _rev का मान बदला जाता है.
किसी Document को अपडेट करने के लिए, हमें Document के _rev मान को पुनर्प्राप्त करना होता है जिसे हम अपडेट करना चाहते हैं.
Document की सामग्री को पुन प्राप्त करने के लिए _rev Number का उपयोग किया जाता है.
{ _id: '001',
_rev: '1-99a7a80ec2a74959885037a16d57924f' }
name: 'Altamas',
age: 28,
designation: 'Project Manager' }
और अब _rev का उपयोग करके "Age" को अपडेट करते है.
//Requiring the package
var PouchDB = require('PouchDB');
//Creating the database object
var db = new PouchDB('Second_Database');
//Preparing the document for update
doc = {
age: 21,
_id: '001',
_rev: '1-99a7a80ec2a74959885037a16d57924f'
}
//Inserting Document
db.put(doc);
//Reading the contents of a Document
db.get('001', function(err, doc) {
if (err) {
return console.log(err);
} else {
console.log(doc);
}
});