PouchDB Tutorial
PouchDB Useful Resources
Selected Reading
- PouchDB - Miscellaneous
- PouchDB - Synchronization
- PouchDB - Replication
- PouchDB - Deleting Attachment
- PouchDB - Retrieving Attachment
- PouchDB - Adding Attachment
- PouchDB - Delete Batch
- PouchDB - Update Batch
- PouchDB - Fetch Batch
- PouchDB - Create Batch
- PouchDB - Delete Document
- PouchDB - Update Document
- PouchDB - Read Document
- PouchDB - Create Document
- PouchDB - Delete Database
- PouchDB - Database Info
- PouchDB - Create Database
- PouchDB - Environment
- PouchDB - Overview
- PouchDB - Home
PouchDB Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
PouchDB - Miscellaneous
PouchDB - Miscellaneous
In this chapter, we will discuss the concepts pke, compaction and retrieval of bulk data from PouchDB.
Compaction
You can reduce the size of a database by removing the unused data using compact() method. You can compact a local database as well as remote database using this method.
Following is an example demonstrating the usage of the compact() method in PouchDB.
//Requiring the package var PouchDB = require( PouchDB ); //Creating the database object var db = new PouchDB( sample_database ); db.compact(function (err, result) { if (err) { return console.log(err); } else { console.log(result); } });
BulkGet Method
You can retrieve a set of documents in bulk using the bulkGet() method. To this method, you need to pass a set of id’s and _rev’s.
Following is an example demonstrating the usage of the bulkGet() method in PouchDB.
//Requiring the package var PouchDB = require( PouchDB ); //Creating the database object var db = new PouchDB( my_database ); //Preparing documents //Inserting Document db.bulkGet({docs: [ { id: "001", rev: "1-5dc593eda0e215c806677df1d12d5c47"}, { id: "002", rev: "1-2bfad8a9e66d2679b99c0cab24bd9cc8"}, { id: "003", rev: "1-7cff4a5da1f97b077a909ff67bd5b047"} ]}, function(err, result) { if (err) { return console.log(err); } else { console.log(result); } });Advertisements