@@ -160,13 +160,29 @@ func DeleteOne(ctx context.Context, coll *mongo.Collection, filter any, opts ...
160160 return nil
161161}
162162
163+ func DeleteOneResult (ctx context.Context , coll * mongo.Collection , filter any , opts ... * options.DeleteOptions ) (* mongo.DeleteResult , error ) {
164+ res , err := coll .DeleteOne (ctx , filter , opts ... )
165+ if err != nil {
166+ return nil , errs .WrapMsg (err , "mongo delete one" )
167+ }
168+ return res , nil
169+ }
170+
163171func DeleteMany (ctx context.Context , coll * mongo.Collection , filter any , opts ... * options.DeleteOptions ) error {
164172 if _ , err := coll .DeleteMany (ctx , filter , opts ... ); err != nil {
165173 return errs .WrapMsg (err , "mongo delete many" )
166174 }
167175 return nil
168176}
169177
178+ func DeleteManyResult (ctx context.Context , coll * mongo.Collection , filter any , opts ... * options.DeleteOptions ) (* mongo.DeleteResult , error ) {
179+ res , err := coll .DeleteMany (ctx , filter , opts ... )
180+ if err != nil {
181+ return nil , errs .WrapMsg (err , "mongo delete many" )
182+ }
183+ return res , nil
184+ }
185+
170186func Aggregate [T any ](ctx context.Context , coll * mongo.Collection , pipeline any , opts ... * options.AggregateOptions ) ([]T , error ) {
171187 cur , err := coll .Aggregate (ctx , pipeline , opts ... )
172188 if err != nil {
@@ -222,3 +238,14 @@ func DecodeOne[T any](decoder func(v any) error) (res T, err error) {
222238 }
223239 return
224240}
241+
242+ func Ignore [T any ](_ T , err error ) error {
243+ return err
244+ }
245+
246+ func IgnoreWarp [T any ](_ T , err error ) error {
247+ if err != nil {
248+ return errs .Wrap (err )
249+ }
250+ return err
251+ }
0 commit comments