Created
August 22, 2020 02:03
-
-
Save jeswinsimon/d1d564cc26c98235ece98d84098f094d to your computer and use it in GitHub Desktop.
Drop all collections in a MongoDB Database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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