1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 16:29:17 +08:00

18 lines
291 B
Go
Raw Normal View History

2022-10-12 18:57:22 +08:00
package service
import (
"context"
"github.com/1Panel-dev/1Panel/backend/global"
2022-10-12 18:57:22 +08:00
"gorm.io/gorm"
)
type dbStr string
2022-10-12 18:57:22 +08:00
func getTxAndContext() (tx *gorm.DB, ctx context.Context) {
db := dbStr("db")
2022-10-12 18:57:22 +08:00
tx = global.DB.Begin()
ctx = context.WithValue(context.Background(), db, tx)
2022-10-12 18:57:22 +08:00
return
}