v0.0.448 wmo marshalHook
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 25s
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 25s
This commit is contained in:
@@ -61,6 +61,10 @@ func (c *Coll[TData]) UpdateMany(ctx context.Context, filterQuery bson.M, update
|
||||
}
|
||||
|
||||
func (c *Coll[TData]) ReplaceOne(ctx context.Context, filterQuery bson.M, value TData) error {
|
||||
for _, hook := range c.marshalHooks {
|
||||
value = hook(value)
|
||||
}
|
||||
|
||||
_, err := c.coll.UpdateOne(ctx, filterQuery, bson.M{"$set": value})
|
||||
if err != nil {
|
||||
return exerr.Wrap(err, "mongo-query[replace-one] failed").
|
||||
@@ -73,6 +77,10 @@ func (c *Coll[TData]) ReplaceOne(ctx context.Context, filterQuery bson.M, value
|
||||
}
|
||||
|
||||
func (c *Coll[TData]) FindOneAndReplace(ctx context.Context, filterQuery bson.M, value TData) (TData, error) {
|
||||
for _, hook := range c.marshalHooks {
|
||||
value = hook(value)
|
||||
}
|
||||
|
||||
mongoRes := c.coll.FindOneAndReplace(ctx, filterQuery, value, options.FindOneAndReplace().SetReturnDocument(options.After))
|
||||
if err := mongoRes.Err(); err != nil {
|
||||
return *new(TData), exerr.Wrap(err, "mongo-query[find-one-and-update] failed").
|
||||
|
Reference in New Issue
Block a user