Skip to content

Instantly share code, notes, and snippets.

@alexjeen
Last active June 16, 2018 09:41
Show Gist options
  • Save alexjeen/f4e1e7ed4175c6661d06b9398d06176e to your computer and use it in GitHub Desktop.
Save alexjeen/f4e1e7ed4175c6661d06b9398d06176e to your computer and use it in GitHub Desktop.
Drops all collections from a MongoDB database
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