Documentation ¶
Index ¶
- Constants
- func CloseDB()
- func CreateBeforeHook(gormDB *gorm.DB)
- func DB() *gorm.DB
- func Init()
- func InitDB() *gorm.DB
- func MaskNotDataError(gormDB *gorm.DB)
- func UpdateBeforeHook(gormDB *gorm.DB)
- func UpdateCreatedTimeHook(db *gorm.DB)
- func UpdateDeletedTimeHook(db *gorm.DB)
- func UpdateIdHook(db *gorm.DB)
- func UpdateLastModifiedTimeHook(db *gorm.DB)
- type LoggerWrapper
- func (l *LoggerWrapper) Error(_ context.Context, msg string, data ...interface{})
- func (l *LoggerWrapper) Info(_ context.Context, msg string, data ...interface{})
- func (l *LoggerWrapper) LogMode(level gormLog.LogLevel) gormLog.Interface
- func (l *LoggerWrapper) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l *LoggerWrapper) Warn(_ context.Context, msg string, data ...interface{})
- type MyNamingStrategy
- type OptionFunc
- type Options
Constants ¶
View Source
const ( ErrorsGormDBCreateParamsNotPtr string = "gorm Create 函数的参数必须是一个指针, 为了完美支持 gorm 的所有回调函数,请在参数前面添加 & " ErrorsGormDBUpdateParamsNotPtr string = "" /* 179-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
func CreateBeforeHook ¶
InterceptCreatePramsNotPtrError 拦截 create 函数参数如果是非指针类型的错误,新用户最容犯此错误
func MaskNotDataError ¶
MaskNotDataError 解决gorm v2 包在查询无数据时,报错问题(record not found),但是官方认为报错是应该是,我们认为查询无数据,代码一切ok,不应该报错
func UpdateBeforeHook ¶
UpdateBeforeHook InterceptUpdatePramsNotPtrError 拦截 save、update 函数参数如果是非指针类型的错误 对于开发者来说,以结构体形式更新数,只需要在 update 、save 函数的参数前面添加 & 即可 最终就可以完美兼支持、兼容 gorm 的所有回调函数 但是如果是指定字段更新,例如: UpdateColumn 函数则只传递值即可,不需要做校验
func UpdateCreatedTimeHook ¶
func UpdateDeletedTimeHook ¶
func UpdateIdHook ¶
Types ¶
type LoggerWrapper ¶
type LoggerWrapper struct { gormLog.Writer gormLog.Config // contains filtered or unexported fields }
func (*LoggerWrapper) Error ¶
func (l *LoggerWrapper) Error(_ context.Context, msg string, data ...interface{})
Error print error messages
func (*LoggerWrapper) Info ¶
func (l *LoggerWrapper) Info(_ context.Context, msg string, data ...interface{})
Info print info
func (*LoggerWrapper) LogMode ¶
func (l *LoggerWrapper) LogMode(level gormLog.LogLevel) gormLog.Interface
LogMode log mode
type MyNamingStrategy ¶
type MyNamingStrategy struct {
schema.NamingStrategy
}
func (MyNamingStrategy) JoinTableName ¶
func (ns MyNamingStrategy) JoinTableName(str string) string
func (MyNamingStrategy) TableName ¶
func (ns MyNamingStrategy) TableName(str string) string
type OptionFunc ¶
type OptionFunc func(log *LoggerWrapper)
type Options ¶
type Options interface {
// contains filtered or unexported methods
}
尝试从外部重写内部相关的格式化变量
func SetErrStrFormat ¶
func SetTracErrStrFormat ¶
func SetTracWarnStrFormat ¶
func SetTraceStrFormat ¶
func SetWarnStrFormat ¶
Click to show internal directories.
Click to hide internal directories.