Created
June 13, 2016 20:22
-
-
Save ddre54/bfce63aee775ed14125b2b9dddec4128 to your computer and use it in GitHub Desktop.
Mongodb: Prints all the sparse indexes in a db
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
// Prints all the sparse indexes in the db | |
db.getCollectionNames().forEach(function(collection) { | |
indexes = db[collection].getIndexes(); | |
print("Indexes for " + collection + ":"); | |
indexes.forEach(function(index) { | |
if (index['sparse']) { | |
printjson(index); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment