Kamva / mgm

Mongo Go Models (mgm) is a fast and simple MongoDB ODM for Go (based on official Mongo Go Driver)
Apache License 2.0
754 stars 63 forks source link

[New-Feature] DeleteMany by Filter #40

Closed gigi214 closed 3 years ago

gigi214 commented 3 years ago

Firstly, congratulation guys, it's a great project. I've got an idea to enhance it.

Is your feature request related to a problem? Please describe. I'd the necessity to delete many documents following some filters. Impossibile to do it with the current lib. I just delete a single document per time. and it's very annoying to making a lot of "get" and the related "delete".

Describe the solution you'd like It would be great if I could use a query like in the Find operation to delete more than one document per time. Also following the same rules for the filter that accepts the official driver.

Describe alternatives you've considered The only alternative that I found is to use the mongodb official driver.

mehran-prs commented 3 years ago

Hi @gigi214, we're glad that you like it :)

mgm is a wrapper around the official MongoDB driver, it supports all MongoDB features. Any filter that you can use in the MongoDB official driver, you can use it here too. e.g.,

mgm.Coll(&Book{}).DeleteMany(context.Background(),bson.M{"name":"example_filter"})
gigi214 commented 3 years ago

Oh Sorry, I didn't figure out this possibility. Thanks @mehran-prs.