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
To delete all documents in a collection, pass an empty document ( {} ). Optional. To limit the deletion to just one document, set to true . Omit to use the default value of false and delete all documents matching the deletion criteria.
remove() The remove() method removes documents from the database. It can remove one or all documents from the collection that matches the given query expression.
The drop command removes the specified collection or view from the federated database instance storage configuration. Use the wildcard "*" to remove all collections generated by the wildcard collection function (that is, collectionName() ), including the wildcard collection rule itself.
Casbah's equivalent to the shells {}
empty document operator is `MongoDBObject.empty
This should work -
db.things.remove(MongoDBObject.empty)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With