goext/wmo/queryDelete.go

26 lines
496 B
Go
Raw Permalink Normal View History

2023-06-06 21:33:49 +02:00
package wmo
2023-06-07 10:42:56 +02:00
import (
"context"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
)
2023-06-06 21:33:49 +02:00
func (c *Coll[TData]) DeleteOne(ctx context.Context, id EntityID) error {
_, err := c.coll.DeleteOne(ctx, bson.M{"_id": id})
if err != nil {
return err
}
return nil
}
func (c *Coll[TData]) DeleteMany(ctx context.Context, filterQuery bson.M) (*mongo.DeleteResult, error) {
res, err := c.coll.DeleteMany(ctx, filterQuery)
if err != nil {
return nil, err
}
return res, nil
}