From 170f43d8062bf8dcd37d6f649492114ad4f7a5d9 Mon Sep 17 00:00:00 2001 From: Robin Willmann Date: Tue, 26 Sep 2023 14:40:56 +0200 Subject: [PATCH] WMO: fix FindOneAndReplace not using FindOneAndReplace --- wmo/queryUpdate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wmo/queryUpdate.go b/wmo/queryUpdate.go index 1885625..2bd4f20 100644 --- a/wmo/queryUpdate.go +++ b/wmo/queryUpdate.go @@ -73,7 +73,7 @@ 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) { - mongoRes := c.coll.FindOneAndUpdate(ctx, filterQuery, bson.M{"$set": value}, options.FindOneAndUpdate().SetReturnDocument(options.After)) + 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"). Str("collection", c.Name()).