Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MongoDB Get collections storage sizes in GB sorted
(() => {
let datas = [];
db.getCollectionNames().forEach(colName => {
let stats = db.getCollection(colName).stats();
datas.push({
colName,
size : stats.storageSize,
humanSize: (stats.storageSize / (1024*1024*1024)) + ' GB'
});
})
return datas.sort((a,b) => {
return b.size - a.size;
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.