Skip to content

Instantly share code, notes, and snippets.

@droustchev
Last active August 29, 2015 13:56
Show Gist options
  • Save droustchev/8921077 to your computer and use it in GitHub Desktop.
Save droustchev/8921077 to your computer and use it in GitHub Desktop.
Small helper function that enables you to drop collections based on their name. Use with caution!
function dropCollections (colName) {
var collectionNames = db.getCollectionNames();
for (var i=0,len=collectionNames.length; i<len; i++) {
var collectionName = collectionNames[i];
if(collectionName.indexOf(colName) == 0) {
db[collectionName].drop();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment