I have a normal (not GridFS) collection in a MongoDB I need to access to and delete some documents. I want/need to do this without using a class.
Have tried a few things yesterday/today and searched the web alot and tried a number of things.
Can't work out why deletemany isn't working for me. I have tried so many things I deleted all the code I tried and want to start fresh.
Are there decent examples some one can share a link to? or maybe some code example just here?
Thanks Russell
the following would be the most convenient way. it uses the implicit operator to convert json string to filterdefinition. so no need for a class.
var collection = new MongoClient("mongodb://localhost")
.GetDatabase("test")
.GetCollection<object>("person");
collection.DeleteMany("{ name : 'John Doe' }");
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