Created
August 20, 2018 20:31
-
-
Save bench/928bd1f27c6ee939dcdcfef4607b42ca to your computer and use it in GitHub Desktop.
remove all documents 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
// This method preserves mongo indexes | |
db.getCollectionNames().forEach(function(collname) { | |
db[collname].remove({}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment