This commit is contained in:
Mike Schwörer 2023-06-06 21:22:44 +02:00
parent c338d23070
commit b02e1d2e85
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF

View File

@ -129,7 +129,16 @@ func (c *Coll[TData]) ReplaceOne(ctx context.Context, id any, value TData) error
return nil
}
func (c *Coll[TData]) UpdateOne(ctx context.Context, id any, updateQuery any) error {
func (c *Coll[TData]) UpdateOne(ctx context.Context, filterQuery any, updateQuery any) error {
_, err := c.coll.UpdateOne(ctx, filterQuery, updateQuery)
if err != nil {
return err
}
return nil
}
func (c *Coll[TData]) UpdateOneByID(ctx context.Context, id any, updateQuery any) error {
_, err := c.coll.UpdateOne(ctx, bson.M{"_id": id}, updateQuery)
if err != nil {
return err
@ -163,6 +172,15 @@ func (c *Coll[TData]) DeleteOne(ctx context.Context, id any) error {
return nil
}
func (c *Coll[TData]) DeleteMany(ctx context.Context, filterQuery any) (*mongo.DeleteResult, error) {
res, err := c.coll.DeleteMany(ctx, filterQuery)
if err != nil {
return nil, err
}
return res, nil
}
func (c *Coll[TData]) List(ctx context.Context, filter ct.Filter, pageSize *int, inTok ct.CursorToken) ([]TData, ct.CursorToken, error) {
if inTok.Mode == ct.CTMEnd {
return make([]TData, 0), ct.End(), nil