Skip to content

Commit e488e67

Browse files
author
phuong
committed
update mocom
1 parent 147c99a commit e488e67

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

mocom/update.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,12 @@ func UpdateOne[T Model](ctx context.Context, filter interface{}, update interfac
1212
return CollWrite(t.CollName()).UpdateOne(ctx, filter, update, opts...)
1313
}
1414

15-
func UpdateAndReturn[T Model](ctx context.Context, filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions) (ptrT *T, err error) {
15+
func UpdateAndReturn[T Model](ctx context.Context, filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions) (*T, error) {
1616
var t T
1717
res := CollWrite(t.CollName()).FindOneAndUpdate(ctx, filter, update, opts...)
1818

19-
err = res.Decode(ptrT)
20-
if err != nil {
21-
return ptrT, err
22-
}
23-
24-
return
19+
err := res.Decode(&t)
20+
return &t, err
2521
}
2622

2723
func UpdateMany[T Model](ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error) {

0 commit comments

Comments
 (0)