Skip to content

Instantly share code, notes, and snippets.

@ddre54
Created June 13, 2016 20:22
Show Gist options
  • Save ddre54/bfce63aee775ed14125b2b9dddec4128 to your computer and use it in GitHub Desktop.
Save ddre54/bfce63aee775ed14125b2b9dddec4128 to your computer and use it in GitHub Desktop.
Mongodb: Prints all the sparse indexes in a db
// 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