I have some data in the pouchdb, I want to show the total rows in pouchdb, how can I do it?
angular.module("pouchapp", ["ui.router"])
.run(function($pouchDB) {
$pouchDB.setDatabase("dbinfo");
//console.log($pouchDB.length); //show total rows in pouchdb
});
.service("$pouchDB", ["$rootScope", "$q", function($rootScope, $q) {
var database;
this.setDatabase = function(databaseName) {
database = new PouchDB(databaseName);
}
}]);
@Phonolog suggested allDocs() but I would recommend using info() as this has less overhead and will be faster.
$pouchDB.info().then(info => console.log(info.doc_count))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With