Created
July 13, 2017 12:29
-
-
Save petermd/427fce0e07ad9ead02a74d576508b6fe to your computer and use it in GitHub Desktop.
Get database collections and size sorted in descending order
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 collectionNames = db.getCollectionNames(), stats = []; | |
collectionNames.forEach(function (n) { stats.push(db[n].stats()); }); | |
stats = stats.sort(function(a, b) { return b['size'] - a['size']; }); | |
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize']/(1024*1024) + ")"); } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment