Created
November 9, 2014 16:17
-
-
Save minmax/0a8564015f25745f1f44 to your computer and use it in GitHub Desktop.
Print mongo collections names and objects count
This file contains hidden or 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 dbs_names = db.adminCommand('listDatabases'); | |
for (var i = 0; i < dbs_names.databases.length; i += 1) { | |
var current_db = connect(dbs_names.databases[i].name); | |
var collection_names = current_db.getCollectionNames(); | |
for (var j = 0; j < collection_names.length; j += 1) { | |
var collection = current_db[collection_names[j]]; | |
var size = collection.stats().count; | |
print(dbs_names.databases[i].name + '\t' + collection_names[j] + ':\t' + size); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment