Add query context support for an array deleting

v2
Nikita Tokarchuk 4 years ago
parent 08397650c6
commit 73dc4974a2
  1. 3
      mongox/database/deletearray.go

@ -39,6 +39,7 @@ func (d *Database) DeleteArray(target interface{}, filters ...interface{}) (err
opts := options.Delete()
ids := primitive.A{}
composed := query.Compose(filters...)
ctx := query.WithContext(d.Context(), composed)
for i := 0; i < targetLen; i++ {
elem := targetSliceV.Index(i)
@ -51,7 +52,7 @@ func (d *Database) DeleteArray(target interface{}, filters ...interface{}) (err
composed.And(primitive.M{"_id": primitive.M{"$in": ids}})
result, err := collection.DeleteMany(d.Context(), composed.M(), opts)
result, err := collection.DeleteMany(ctx, composed.M(), opts)
if err != nil {
return
}

Loading…
Cancel
Save