Skip to content

Instantly share code, notes, and snippets.

@wtrocki
Created January 22, 2016 11:15
Show Gist options
  • Save wtrocki/a1691b98a518dda7e072 to your computer and use it in GitHub Desktop.
Save wtrocki/a1691b98a518dda7e072 to your computer and use it in GitHub Desktop.
Drop collections basing on specified pattern - pattern name.js
var namePattern=/fh_testing/;
var names = db.getCollectionNames().filter(function (collection) { return namePattern.test(collection) });
for(var i = 0; i < names.length; i++) {
db.getCollection(names[i]).drop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment