Deepak jha Deepak jha - 1 year ago 101
Node.js Question

Get count of a databse in MongoDB

I am trying to get count of all the documents of all the collections in a single MongoDB database.

For now, I am looping through all the collections to get the total count.
Is there any way (MongoDB command/ NodeJS way) of achieving this?

Answer Source

What about using db.stats() and db.collection.stats() queries ( ? Which returns the number of collections and the objects.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download