By Alvin Alexander. Last updated: June 6, 2016
To remove all documents in a MongoDB collection (from the command line) use the remove function, and give it an empty set of parentheses, like this:
// remove all documents in the "stickynotes" collection db.stickynotes.remove({})
You can do the same thing from your Java, Scala, Ruby, Python, PHP, etc. code, just created an empty MongoDbObject and supply it as an argument to remove(). (Of course you'll want to test this somewhere besides your production systems.)