Skip to content

Instantly share code, notes, and snippets.

@jeswinsimon
Created August 22, 2020 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeswinsimon/d1d564cc26c98235ece98d84098f094d to your computer and use it in GitHub Desktop.
Save jeswinsimon/d1d564cc26c98235ece98d84098f094d to your computer and use it in GitHub Desktop.
Drop all collections in a MongoDB Database
var dbName = 'DatabaseName';
db.getSiblingDB(dbName).getCollectionNames().forEach(function(collName) {
if (!collName.startsWith("system.")) {
db[collName].drop();
print('Dropped Collection: ' + collName);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment