Skip to content

Instantly share code, notes, and snippets.

@Voronenko
Created September 11, 2015 19:01
Show Gist options
  • Save Voronenko/87073d80f144640257ec to your computer and use it in GitHub Desktop.
Save Voronenko/87073d80f144640257ec to your computer and use it in GitHub Desktop.
Drop mongo databases by pattern
var regExp = /_test_/;
db.getMongo().getDBNames().filter(function(name){
return name.match(regExp)
}).forEach(function(name){
print(name);
var thedb = db.getMongo().getDB( name );
thedb.dropDatabase();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment