Skip to content

Instantly share code, notes, and snippets.

@csirac2
Created May 8, 2011 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csirac2/961253 to your computer and use it in GitHub Desktop.
Save csirac2/961253 to your computer and use it in GitHub Desktop.
MongoDB count all documents in a collection across all databases
var databases = db.adminCommand('listDatabases')['databases'];
var count = 0;
for (var item in databases) {
print(databases[item]['name']);
count = count + db.getMongo().getDB(databases[item]['name']).current.count();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment