Skip to content

Instantly share code, notes, and snippets.

@bench
Created August 20, 2018 20:31
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 bench/928bd1f27c6ee939dcdcfef4607b42ca to your computer and use it in GitHub Desktop.
Save bench/928bd1f27c6ee939dcdcfef4607b42ca to your computer and use it in GitHub Desktop.
remove all documents from a mongoDB database
// 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