mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
20 lines
265 B
Go
20 lines
265 B
Go
package tx
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
func NewGorm(db *gorm.DB) Tx {
|
|
return &_Gorm{tx: db}
|
|
}
|
|
|
|
type _Gorm struct {
|
|
tx *gorm.DB
|
|
}
|
|
|
|
func (g *_Gorm) Transaction(fn func(tx any) error) error {
|
|
return g.tx.Transaction(func(tx *gorm.DB) error {
|
|
return fn(tx)
|
|
})
|
|
}
|