PouchDB in Hindi Fetch Batch




PouchDB में Database से Multiple/bulk Documents को allDocs() Method से Read और Retrieved किया जा सकता है.

Syntax

PouchDB के allDocs () Method के लिए Syntax नीचे दिया गया है यह एक Callback Function को इस Method में Recognized किया जाता है.

db.allDocs()

Example

Database में सभी Documents को पुन प्राप्त करने के लिए my_database नामक स्थानीय रूप से Store है db.allDocs () System का उपयोग करते है.

Documents की सरणी वस्तुओं के रूप में होती है इस System का उपयोग करके पुनर्प्राप्त की जाती है और प्रत्येक Documents के Materials प्राप्त करने के लिए हमें docs.rows के रूप में Call करने की आवश्यकता होती है.

//Requiring the package
var PouchDB = require('PouchDB');
//Creating the database object
var db = new PouchDB('my_database');
//Retrieving all the documents in PouchDB
db.allDocs(function(err, docs) {
 if (err) {
   return console.log(err);
 } else {
   console.log (docs.rows);
 }
});

अब हम Read_All_Document.js नामक एक File को बनाते है और उसमें उपरोक्त Code को Save कर लेते है.

C:\PouchDB_Examples >node Read_All_Document.js

सभी Documents जो स्थानीय तौर पर store है my_database नामक Database मे उनको इस तरह द्वारा पढ़ा जाता है.

[
 {
   id: '001',
   key: '001',
   value: { rev: '1-9dc57f5faa7ea90eeec22eba8bfd05f5' }
 },
 {
   id: '002',
   key: '002',
   value: { rev: '1-9bf80afcedb9f8b5b35567292affb254' }
  },
 {
   id: '003',
   key: '003',
   value: { rev: '1-1204f108e41bf8baf867856d5da16c57' }
 }
]

AllDocs () Method का उपयोग करके, प्रत्येक Documents के केवल _id, key और _rev फ़ील्ड को देखा जाता है.

//Requiring the package
var PouchDB = require('PouchDB');
//Creating the database object
var db = new PouchDB('my_database');
//Retrieving all the documents in PouchDB
db.allDocs({include_docs: true}, function(err, docs) {
 if (err) {
   return console.log(err);
 } else {
   console.log (docs.rows);
 }
});

Output