v0.0.139
This commit is contained in:
parent
2ad820be8d
commit
5fb2f8a312
@ -43,3 +43,14 @@ func (c *Coll[TData]) ReplaceOne(ctx context.Context, id EntityID, value TData)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Coll[TData]) FindOneAndReplace(ctx context.Context, id EntityID, value TData) (TData, error) {
|
||||
var res TData
|
||||
|
||||
err := c.coll.FindOneAndUpdate(ctx, bson.M{"_id": id}, value, options.FindOneAndUpdate().SetReturnDocument(options.After)).Decode(&res)
|
||||
if err != nil {
|
||||
return *new(TData), err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user