How to clear/drop/empty a MongoDb collection with Casbah

jolivier picture jolivier · Sep 6, 2012 · Viewed 8.2k times · Source

I started using MongoDb in Scala via Casbah but cannot find on the Casbah documentation / google the way to drop the content of a collection. The MongoDd doc says the MongoDb shell command to do so is

db.things.remove({}); 

But how can we achieve the same via Casbah?

Thanks in advance,

Olivier

Answer

Brendan W. McAdams picture Brendan W. McAdams · Sep 6, 2012

Casbah's equivalent to the shells {} empty document operator is `MongoDBObject.empty

This should work -

db.things.remove(MongoDBObject.empty)