This commit is contained in:
wangchuxiao
2023-02-10 11:03:03 +08:00
parent 5d7809624c
commit 79c30fdc69
8 changed files with 23 additions and 23 deletions
+9
View File
@@ -150,3 +150,12 @@ func MongoTransaction(ctx context.Context, mgo *mongo.Client, fn func(ctx mongo.
}
return utils.Wrap(sess.CommitTransaction(sCtx), "")
}
func getTxCtx(ctx context.Context, tx []any) context.Context {
if len(tx) > 0 {
if ctx, ok := tx[0].(mongo.SessionContext); ok {
return ctx
}
}
return ctx
}
-9
View File
@@ -111,15 +111,6 @@ type SuperGroupMongoDriver struct {
// panic("implement me")
// }
func (s *SuperGroupMongoDriver) getTxCtx(ctx context.Context, tx []any) context.Context {
if len(tx) > 0 {
if ctx, ok := tx[0].(mongo.SessionContext); ok {
return ctx
}
}
return ctx
}
//func (s *SuperGroupMongoDriver) Transaction(ctx context.Context, fn func(ctx mongo.SessionContext) error) error {
// sess, err := s.MgoClient.StartSession()
// if err != nil {