Add context query support to a single deleting

v2
Nikita Tokarchuk 4 years ago
parent 50e947b203
commit 8fcd764a8c
  1. 3
      mongox/database/deleteone.go

@ -19,6 +19,7 @@ func (d *Database) DeleteOne(target interface{}, filters ...interface{}) (err er
opts := &options.FindOneAndDeleteOptions{}
composed := query.Compose(filters...)
protected := base.GetProtection(target)
ctx := query.WithContext(d.Context(), composed)
opts.Sort = composed.Sorter()
@ -32,7 +33,7 @@ func (d *Database) DeleteOne(target interface{}, filters ...interface{}) (err er
protected.V = time.Now().Unix()
}
result := collection.FindOneAndDelete(d.Context(), composed.M(), opts)
result := collection.FindOneAndDelete(ctx, composed.M(), opts)
if result.Err() != nil {
return fmt.Errorf("can't create find one and delete result: %w", result.Err())
}

Loading…
Cancel
Save