Compare commits

...

1 Commits

Author SHA1 Message Date
e89e2c18f2 v0.0.141 2023-06-07 10:56:11 +02:00

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 {