Created
May 7, 2018 05:43
-
-
Save Maxhodges/9375cc3cb77e856a695cc51c6fbde5b1 to your computer and use it in GitHub Desktop.
find 'safe' collection indexes
This file contains 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
use whiterabbit | |
db.indexes.find(); | |
db.shippingOrders.getIndexes(); | |
db.getCollectionNames().forEach(function(collection) { | |
if (db[collection]) { | |
indexes = db[collection].getIndexes(); | |
var filterIndexes = Object.keys(indexes).filter(function(i) { | |
return Object.hasOwnProperty.call(indexes[i], "safe") | |
}) | |
if (filterIndexes.length > 0) { | |
indexNames = filterIndexes.map(function(i) {return indexes[i].name}); | |
print("Indexes for " + collection + ' ' + JSON.stringify(indexNames)); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment