Reputation: 17622
As explained here, db.bios.remove()
deletes all the documents from the bios
collection of currently connected DB. What is the equivalent method for this functionality in MongoDB Java API?
I did not find any methods like DB.removeCollection(..)
or DBCollection.removeAll()
. Please help me.
Upvotes: 0
Views: 130
Reputation: 69663
You can do that by simply calling the remove method with an empty object.
yourDBCollection.remove(new BasicDBObject());
The equivalent Mongo shell command would be db.bios.remove({});
Remember that MongoDB query objects work like filters: They let anything through which doesn't explicitely violates them.
Upvotes: 1