Add context query support to a single deleting

This commit is contained in:
Nikita Tokarchuk
2020-07-22 04:45:32 +02:00
parent 50e947b203
commit 8fcd764a8c
+2 -1
View File
@@ -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())
}