add export func reame
添加函数支持
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
var gloabIsRelated bool // 全局预加载
|
||||
|
||||
// prepare for outher
|
||||
type _BaseMgr struct {
|
||||
*gorm.DB
|
||||
@@ -23,8 +25,18 @@ func (obj *_BaseMgr) GetDB() *gorm.DB {
|
||||
return obj.DB
|
||||
}
|
||||
|
||||
// IsRelated Query foreign key Association.是否查询外键关联(gorm.Related)
|
||||
func (obj *_BaseMgr) IsRelated(b bool) {
|
||||
// UpdateDB update gorm.DB info
|
||||
func (obj *_BaseMgr) UpdateDB(db *gorm.DB) {
|
||||
obj.DB = db
|
||||
}
|
||||
|
||||
// GetIsRelated Query foreign key Association.获取是否查询外键关联(gorm.Related)
|
||||
func (obj *_BaseMgr) GetIsRelated() bool {
|
||||
return obj.isRelated
|
||||
}
|
||||
|
||||
// SetIsRelated Query foreign key Association.设置是否查询外键关联(gorm.Related)
|
||||
func (obj *_BaseMgr) SetIsRelated(b bool) {
|
||||
obj.isRelated = b
|
||||
}
|
||||
|
||||
@@ -42,3 +54,13 @@ type optionFunc func(*options)
|
||||
func (f optionFunc) apply(o *options) {
|
||||
f(o)
|
||||
}
|
||||
|
||||
// OpenRelated 打开全局预加载
|
||||
func OpenRelated() {
|
||||
gloabIsRelated = true
|
||||
}
|
||||
|
||||
// CloseRelated 关闭全局预加载
|
||||
func CloseRelated() {
|
||||
gloabIsRelated = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user