Created
May 8, 2011 09:30
-
-
Save csirac2/961253 to your computer and use it in GitHub Desktop.
MongoDB count all documents in a collection across all databases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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