You can get the fundamental data about the information base utilizing the technique named data()
Syntax
Following is the grammar of utilizing the information() strategy for PouchDB. This technique acknowledges a callback work.
db.info([callback])
Model
Following is an illustration of recovering data set data utilizing the information() strategy. Here, we are showing the data of the information base named my_database. If there should arise an occurrence of blunder, the mistake will be shown on the reassure.
//Requiring the package
var PouchDB = require('PouchDB');
//Creating the database object
var db = new PouchDB('my_database');
//Database information
db.info(function(err, info) {
if (err) {
return console.log(err);
} else {
console.log(info);
}
});
Save the above code in a record with the name Database_info.js. Open the order provoke and execute the JavaScript document utilizing hub as demonstrated beneath.
C:\PouchDB_Examples>node Database_info.js
This will show the information of the predetermined data set as follows.
{
doc_count: 0,
update_seq: 0,
backend_adapter: 'LevelDOWN',
db_name: 'my_database',
auto_compaction: false,
adapter: 'leveldb'
}
Far off Database Info
Similarly, you get the data of an information base that is saved distantly on the worker (CouchDB). To do as such, rather than information base name, you need to pass the way to the necessary data set in CouchDB.
Model
Following is an illustration of recovering data of a data set that is saved in the CouchDB worker. This code gives you data of an information base named my_database.
//Requiring the package
var PouchDB = require('PouchDB');
//Creating the database object
var db = new PouchDB('http://localhost:5984/my_database');
//Database information
db.info(function(err, info) {
if (err) {
return console.log(err);
} else {
console.log(info);
}
});
Save the above code in a record with the name Database_ Remote_info.js. Open the order provoke and execute the JavaScript document utilizing hub as demonstrated beneath.
C:\PouchDB_Examples>node Database_Remote_info.js
This will show the information of the predefined data set as follows.
{
db_name: 'my_database',
doc_count: 0,
doc_del_count: 0,
update_seq: 0,
purge_seq: 0,
compact_running: false,
disk_size: 79,
data_size: 0,
instance_start_time: '1458209191708486',
disk_format_version: 6,
committed_update_seq: 0,
host: 'http://localhost:5984/my_database/',
auto_compaction: false,
adapter: 'http'
}