How to count the number of documents in a mongodb collection

Traverse to the database where your collection resides using the command:

use databasename;

Then invoke the count() function on the collection in the database.

var value = db.collection.count();

and then print(value) or simply value, would give you the count of documents in the collection named collection.

Refer: http://docs.mongodb.org/v2.2/tutorial/getting-started-with-the-mongo-shell/

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)