feat: 添加 db(gorm) 支持
This commit is contained in:
22
database/db/db.go
Normal file
22
database/db/db.go
Normal file
@ -0,0 +1,22 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type DB interface {
|
||||
Session(ctx context.Context) *gorm.DB
|
||||
}
|
||||
|
||||
type db struct {
|
||||
tx *gorm.DB
|
||||
}
|
||||
|
||||
var (
|
||||
Default DB
|
||||
)
|
||||
|
||||
func (db *db) Session(ctx context.Context) *gorm.DB {
|
||||
return db.tx.Session(&gorm.Session{Context: ctx})
|
||||
}
|
Reference in New Issue
Block a user