This commit is contained in:
Mike Schwörer 2023-06-07 10:56:11 +02:00
parent b16d5152c7
commit e89e2c18f2
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF

View File

@ -3,6 +3,7 @@ package wmo
import ( import (
"context" "context"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/options"
) )
@ -35,6 +36,15 @@ func (c *Coll[TData]) UpdateOneByID(ctx context.Context, id EntityID, updateQuer
return nil return nil
} }
func (c *Coll[TData]) UpdateMany(ctx context.Context, filterQuery bson.M, updateQuery bson.M) (*mongo.UpdateResult, error) {
res, err := c.coll.UpdateMany(ctx, filterQuery, updateQuery)
if err != nil {
return nil, err
}
return res, nil
}
func (c *Coll[TData]) ReplaceOne(ctx context.Context, id EntityID, value TData) error { func (c *Coll[TData]) ReplaceOne(ctx context.Context, id EntityID, value TData) error {
_, err := c.coll.UpdateOne(ctx, bson.M{"_id": id}, value) _, err := c.coll.UpdateOne(ctx, bson.M{"_id": id}, value)
if err != nil { if err != nil {