Documentation ¶
Index ¶
- func InitDB(name string, dsn string) (*gorm.DB, error)
- func MicrosecondsStr(elapsed time.Duration) string
- type GormLogger
- func (l GormLogger) Error(ctx context.Context, str string, args ...interface{})
- func (l GormLogger) Info(ctx context.Context, str string, args ...interface{})
- func (l GormLogger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
- func (l GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l GormLogger) Warn(ctx context.Context, str string, args ...interface{})
- type TimeBase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MicrosecondsStr ¶ added in v1.1.20
MicrosecondsStr 将 time.Duration 类型(nano seconds 为单位) 输出为小数点后 3 位的 ms (microsecond 毫秒,千分之一秒)
Types ¶
type GormLogger ¶ added in v1.1.20
GormLogger 操作对象,实现 gormlogger.Interface
func NewGormLogger ¶ added in v1.1.20
func NewGormLogger() GormLogger
NewGormLogger 外部调用。实例化一个 GormLogger 对象,示例:
DB, err := gorm.Open(dbConfig, &gorm.Config{ Logger: logger.NewGormLogger(), })
func (GormLogger) Error ¶ added in v1.1.20
func (l GormLogger) Error(ctx context.Context, str string, args ...interface{})
Error 实现 gormlogger.Interface 的 Error 方法
func (GormLogger) Info ¶ added in v1.1.20
func (l GormLogger) Info(ctx context.Context, str string, args ...interface{})
Info 实现 gormlogger.Interface 的 Info 方法
func (GormLogger) LogMode ¶ added in v1.1.20
func (l GormLogger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
LogMode 实现 gormlogger.Interface 的 LogMode 方法
type TimeBase ¶ added in v1.1.21
type TimeBase struct { CreatedAt timelib.JsonTime `gorm:"type:timestamp NULL;default:NULL;index" json:"created_at"` UpdatedAt timelib.JsonTime `gorm:"type:timestamp NULL;default:NULL" json:"updated_at"` DeletedAt *timelib.JsonTime `gorm:"type:timestamp NULL;default:NULL;index" json:"-"` }
TimeBase TimeBase
Click to show internal directories.
Click to hide internal directories.