Created
January 21, 2025 06:49
-
-
Save sar-joshi/c8fc70ea94ba19414ebba2e691763594 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
// Create an object to store all index information | |
var clusterIndexes = {}; | |
db.getMongo().getDBs().databases.forEach(function(database) { | |
if (database.name !== 'admin' && database.name !== 'local' && database.name !== 'config') { | |
clusterIndexes[database.name] = {}; | |
var dbs = db.getSiblingDB(database.name); | |
dbs.getCollectionNames().forEach(function(collName) { | |
clusterIndexes[database.name][collName] = db.getCollection(collName).getIndexes(); | |
}); | |
} | |
}); | |
// Print the final structured output | |
printjson(clusterIndexes); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment