mirror of
https://github.com/mainnika/mongox-go-driver.git
synced 2026-05-22 15:53:36 +00:00
Use delete by id if target is provided
This commit is contained in:
@@ -21,6 +21,10 @@ func DeleteOne(db *mongox.Database, target interface{}, filters ...interface{})
|
||||
|
||||
opts.Sort = composed.Sorter()
|
||||
|
||||
if target != nil {
|
||||
composed.And(primitive.M{"_id": base.GetID(target)})
|
||||
}
|
||||
|
||||
if protected != nil {
|
||||
if protected.X.IsZero() {
|
||||
composed.And(primitive.M{"_x": primitive.M{"$exists": false}})
|
||||
|
||||
Reference in New Issue
Block a user