Skip to content

Instantly share code, notes, and snippets.

@mhelmstetter
Created August 24, 2021 18:48
Show Gist options
  • Save mhelmstetter/869fbe323691fc50b588ff201fa1382b to your computer and use it in GitHub Desktop.
Save mhelmstetter/869fbe323691fc50b588ff201fa1382b to your computer and use it in GitHub Desktop.
db = db.getSiblingDB("admin");
dbs = db.runCommand({ "listDatabases": 1 }).databases;
dbs.forEach(function(database) {
db = db.getSiblingDB(database.name);
cols = db.getCollectionNames();
cols.forEach(function(col) {
print(`*** ${col} ***`);
printjson(db.getCollection(col).getIndexes());
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment