Last active
December 9, 2020 19:12
-
-
Save karan9/7abe7eda52cddedacaa2ff3fa73c0750 to your computer and use it in GitHub Desktop.
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 colls = db.getCollectionNames(); | |
var ret = []; | |
colls.forEach(function(coll) { | |
if (String(coll).startsWith("system")) { | |
return; | |
} | |
var indexes = db.getCollection(coll).getIndexes(); | |
var stats = db.getCollection(coll).aggregate( [ { $indexStats: { } } ] ).toArray(); | |
var len = indexes.length | |
ret.push({ "name": coll, "length": len, "data": stats}); | |
}) | |
printjson(ret) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment