-
-
Save bayleedev/8ce12fda247523e40d5a 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
var r = new RegExp("system"); | |
db.getCollectionNames().forEach( | |
function(c){ | |
if(!r.test(c)){ | |
var indexes = db[c].getIndexes(); | |
indexes.forEach(function(i){ | |
var val = i["key"].toSource(); | |
var trimmedValue = val.substr(1,val.length-2); | |
if (trimmedValue !="{_id:1}") | |
{ | |
print("db."+c+".ensureIndex("+trimmedValue+",{ \"background\":true, \"name\":\"" + i["name"]+"\"});"); | |
} | |
});} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment