PouchDB in Hindi Read Document




Database में बनाए गए Document को पढ़ने या Recover करने के लिए db.get () विधि का उपयोग किया जाता है . यह विधि Document Id और वैकल्पिक Callback Function भी स्वीकार करता है.

Syntax

db.get(document, callback)

Read Document Example

PouchDB में एक Document की सामग्री को Get () Method का उपयोग करते हुए पढ़ने का एक उदाहरण है.

//Requiring the package  
var PouchDB = require('PouchDB');  
//Creating the database object  
var db = new PouchDB('Second_Database');  
//Reading the contents of a Document  
db.get('001', function(err, doc) {  
   if (err) {  
      return console.log(err);  
   } else {  
      console.log(doc);  
   }  
});  

Output

PouchDB सर्वर पर Second_Database में संग्रहीत Document को पढ़ा जाता है.

{ name: 'Altamas',  
  age: 21,  
  designation: 'Web Developer',  
  _id: '001',  
  _rev: '1-99a7a80ec2a74959885037a16d57924f' }  

Read a Document From Remote Database

किसी Remote Database (CouchDB) से कोई Document को Read और Retrieve प्राप्त कर सकते हैं. इसके लिए, आपको CouchDB में Database का Path देना होगा, जिसमें उस Document को शामिल किया गया है जिसे आप Database नाम के बदले में, पढ़ना चाहते हो.

//Requiring the package  
var PouchDB = require('PouchDB');  
//Creating the database object  
var db = new PouchDB('http://localhost:5984/my_database');  
//Reading the contents of a document  
db.get('001', function(err, doc) {  
   if (err) {  
      return console.log(err);  
   } else {  
      console.log(doc);  
   }  
});  

Output