Skip to content

Instantly share code, notes, and snippets.

@andreabalducci
Created March 10, 2017 21:10
Show Gist options
  • Save andreabalducci/742f6b9e58ab2b2f876a92d0c376034c to your computer and use it in GitHub Desktop.
Save andreabalducci/742f6b9e58ab2b2f876a92d0c376034c to your computer and use it in GitHub Desktop.
MongoDB :: Drop all databases
var admin = db.getSiblingDB('admin');
var dbs = db.adminCommand( { listDatabases: 1 } );
dbs.databases.forEach(function(db){
if(db.name !== 'admin' && db.name !== 'local'){
admin.getSiblingDB(db.name).dropDatabase();
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment