Documentation ¶
Index ¶
- Variables
- func CheckMysqlDatabase(c Config) error
- func ModelMap(c entity.Context, i any) map[string]any
- func ParseGormLevel(lvl string) logger.LogLevel
- func RawTableName(i any) string
- type AInt32
- type AInt64
- type AString
- type Config
- type GormDB
- type GormLog
- func (m *GormLog) Error(c entity.Context, s string, p ...any)
- func (m *GormLog) Info(c entity.Context, s string, p ...any)
- func (m *GormLog) LogMode(logger.LogLevel) logger.Interface
- func (m *GormLog) Trace(c entity.Context, begin time.Time, fc func() (string, int64), err error)
- func (m *GormLog) Warn(c entity.Context, s string, p ...any)
- type LogConfig
- type Tabler
- type Transaction
Constants ¶
This section is empty.
Variables ¶
View Source
var DBKey dbKeyType
Functions ¶
func CheckMysqlDatabase ¶
CheckMysqlDatabase 检查数据库是否存在,不存在则创建, for mysql
func ParseGormLevel ¶
ParseLevel takes a string level and returns the Logrus log level constant.
func RawTableName ¶
Types ¶
type Config ¶
type Config struct { // for log SlowThreshold time.Duration `json:"slow_threshold" yaml:"slow_threshold"` LogLevel string `json:"log_level" yaml:"log_level"` UserName string `json:"user_name" yaml:"user_name"` Password string `json:"password" yaml:"password"` Protocol string `json:"protocol" yaml:"protocol"` Host string `json:"host" yaml:"host"` DBName string `json:"db_name" yaml:"db_name"` MaxOpen int `json:"max_open" yaml:"max_open"` MaxIdle int `json:"max_idle" yaml:"max_idle"` MaxLife int `json:"max_life" yaml:"max_life"` Charset string `json:"charset" yaml:"charset"` Params map[string]string `json:"params" yaml:"params"` //DatabaseType default mysql DatabaseType string `json:"database_type" yaml:"database_type"` Tabler }
type GormDB ¶
type GormDB struct { *Config // contains filtered or unexported fields }
MysqlDB 数据库操作实例
func FormatGormDB ¶
func NewOnlyReadGormDB ¶
type GormLog ¶
type GormLog struct { *LogConfig // contains filtered or unexported fields }
func NewGormLog ¶
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
func NewTransaction ¶
func NewTransaction(db *GormDB) *Transaction
func (*Transaction) Commit ¶
func (t *Transaction) Commit(c entity.Context)
Click to show internal directories.
Click to hide internal directories.