Skip to content

Instantly share code, notes, and snippets.

@whatupdave
Created April 29, 2013 21:09
Show Gist options
  • Save whatupdave/5484793 to your computer and use it in GitHub Desktop.
Save whatupdave/5484793 to your computer and use it in GitHub Desktop.
Drop mongo collections with name match
var collectionNames = db.getCollectionNames();
for(var i = 0, len = collectionNames.length; i < len ; i++){
var collectionName = collectionNames[i];
if(collectionName.indexOf('logs_') == 0){
print(i + '/' + len + ':' + collectionName);
db[collectionName].drop();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment