From 8665705f269cb7ef83dbc070f0854156b35bd1f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=8C?= <259278618@qq.com> Date: Tue, 25 Nov 2025 14:19:52 +0800 Subject: [PATCH] =?UTF-8?q?mongo=E5=B7=A5=E5=85=B7=E7=B1=BB=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mongo/mongo.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mongo/mongo.go b/mongo/mongo.go index d41faf3..aadc838 100644 --- a/mongo/mongo.go +++ b/mongo/mongo.go @@ -37,7 +37,7 @@ func init() { } // Find 查询多条记录 -func Find(ctx context.Context, filter bson.M, result interface{}, collection string, opts ...options.FindOptions) (err error) { +func Find(ctx context.Context, filter bson.M, result interface{}, collection string, opts ...options.Lister[options.FindOptions]) (err error) { if err = utils.ValidStructPtr(result); err != nil { return } @@ -50,7 +50,7 @@ func Find(ctx context.Context, filter bson.M, result interface{}, collection str } // FindOne 查询1条记录 -func FindOne(ctx context.Context, filter bson.M, result interface{}, collection string, opts ...options.FindOneOptions) (err error) { +func FindOne(ctx context.Context, filter bson.M, result interface{}, collection string, opts ...options.Lister[options.FindOneOptions]) (err error) { if len(filter) == 0 { err = gerror.New("缺少查询条件") return @@ -67,7 +67,7 @@ func FindOne(ctx context.Context, filter bson.M, result interface{}, collection } // Delete 删除记录 -func Delete(ctx context.Context, filter bson.M, collection string, opts ...options.DeleteOptions) (count int64, err error) { +func Delete(ctx context.Context, filter bson.M, collection string, opts ...options.Lister[options.DeleteManyOptions]) (count int64, err error) { r, err := db.Collection(collection).DeleteMany(ctx, filter, opts...) if err != nil { return @@ -77,7 +77,7 @@ func Delete(ctx context.Context, filter bson.M, collection string, opts ...optio } // Update 修改记录 -func Update(ctx context.Context, filter bson.M, update interface{}, collection string, opts ...options.UpdateOptions) (result *mongo.UpdateResult, err error) { +func Update(ctx context.Context, filter bson.M, update interface{}, collection string, opts ...options.Lister[options.UpdateManyOptions]) (result *mongo.UpdateResult, err error) { result, err = db.Collection(collection).UpdateMany(ctx, filter, update, opts...) if err != nil { return @@ -86,7 +86,7 @@ func Update(ctx context.Context, filter bson.M, update interface{}, collection s } // Insert 插入多条记录 -func Insert(ctx context.Context, documents []interface{}, collection string, opts ...options.InsertManyOptions) (ids []interface{}, err error) { +func Insert(ctx context.Context, documents []interface{}, collection string, opts ...options.Lister[options.InsertManyOptions]) (ids []interface{}, err error) { r, err := db.Collection(collection).InsertMany(ctx, documents, opts...) if err != nil { return