samedi 9 mai 2015

Count total items in mongoDB collection/database

I can't seem to find the answer to this. I wan't a simple return statement of the amount (total) items in my collections.

var mongojs = require('mongojs');
var db = mongojs("myadb",['myadb']);
db.myadb.count(function(used,a){
    console.log(used,a);
});

Null is return. I'm using a mongodb JS library for node and yes, there is records in the database (12)

The documentation states that:

cursor.count(callback)

Thanks.

Aucun commentaire:

Enregistrer un commentaire