gorm v2.0

支持gormv2.0
This commit is contained in:
谢小军
2020-09-24 20:59:50 +08:00
parent 33d22fe2d4
commit f585a627c1
5 changed files with 46 additions and 46 deletions

View File

@@ -3,7 +3,6 @@ package model
import (
"context"
"fmt"
"time"
"gorm.io/gorm"
)
@@ -17,9 +16,8 @@ func UserMgr(db *gorm.DB) *_UserMgr {
if db == nil {
panic(fmt.Errorf("UserMgr need init by db"))
}
timeout := 10 * time.Second
ctx, cancel := context.WithTimeout(context.Background(), timeout)
return &_UserMgr{_BaseMgr: &_BaseMgr{DB: db.Table("user"), isRelated: globalIsRelated, ctx: ctx, cancel: cancel, timeout: timeout}}
ctx, cancel := context.WithCancel(context.Background())
return &_UserMgr{_BaseMgr: &_BaseMgr{DB: db.Table("user"), isRelated: globalIsRelated, ctx: ctx, cancel: cancel, timeout: -1}}
}
// GetTableName get sql table name.获取数据库名字