Last active
June 16, 2018 09:41
-
-
Save alexjeen/f4e1e7ed4175c6661d06b9398d06176e to your computer and use it in GitHub Desktop.
Drops all collections from 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
db.getCollectionNames().forEach( function(collection_name) { | |
if (collection_name.indexOf("system.") == -1) | |
db[collection_name].drop(); | |
else | |
db.collection_name.remove({}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment