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
}