Skip to content

Instantly share code, notes, and snippets.

@mhelmstetter
Created May 18, 2021 20:37
Show Gist options
  • Save mhelmstetter/b73aac64b0a5d7221635a199fc8e6572 to your computer and use it in GitHub Desktop.
Save mhelmstetter/b73aac64b0a5d7221635a199fc8e6572 to your computer and use it in GitHub Desktop.
db.adminCommand( { listDatabases: 1 } ).databases.forEach(function (dbObj) {
var dbName = dbObj["name"];
if (dbName != null) {
var collectionNames = db.getSiblingDB(dbName).getCollectionNames();
collectionNames.forEach(function (collName) {
if (collName != null) {
var count = db.getSiblingDB(dbName).getCollection(collName).count();
print(`${dbName}.${collName}: ${count}`)
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment