Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show total number of rows in pouchdb

Tags:

pouchdb

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);
    }
}]);
like image 905
penguinnnnn Avatar asked Nov 30 '25 11:11

penguinnnnn


1 Answers

@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))
like image 162
cjroth Avatar answered Dec 02 '25 03:12

cjroth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!