Skip to content

Instantly share code, notes, and snippets.

@csirac2
Created April 26, 2011 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csirac2/941875 to your computer and use it in GitHub Desktop.
Save csirac2/941875 to your computer and use it in GitHub Desktop.
MongoDB ensureIndex on all databases
var databases = db.adminCommand('listDatabases')['databases'];
for (var item in databases) {
db = db.getMongo().getDB(item['name']);
db.current.ensureIndex({_web: 1});
db.current.ensureIndex({_topic: 1});
db.current.ensureIndex({'TOPICINFO.author': 1});
db.current.ensureIndex({'TOPICINFO.date': 1});
db.current.ensureIndex({'CREATEINFO.author': 1});
db.current.ensureIndex({'CREATEINFO.date': 1});
db.current.ensureIndex({'TOPICPARENT.name': 1});
db.current.ensureIndex({'FORM.name': 1});
db.current.ensureIndex({'address': 1});
db.current.ensureIndex({'_ACLProfile_DENYTOPICVIEW': 1});
db.current.ensureIndex({'_ACLProfile_ALLOWTOPICVIEW': 1});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment