Documentation ¶
Index ¶
- Constants
- func CloseAllDB() error
- func DB() *gorm.DB
- func DBs() []*gorm.DB
- func DefaultLogger(logCfg *LoggerConfig) logger.Interface
- func RegisterDriver(dType string, provider DatabaseProvider)
- func SetDB(index int, db *gorm.DB)
- type DatabaseConfig
- type DatabaseProvider
- type Datasource
- type Logger
- func (l *Logger) Error(ctx context.Context, str string, args ...interface{})
- func (l *Logger) Info(ctx context.Context, str string, args ...interface{})
- func (l *Logger) LogMode(level logger.LogLevel) logger.Interface
- func (l *Logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l *Logger) Warn(ctx context.Context, str string, args ...interface{})
- type LoggerConfig
Constants ¶
View Source
const ( DriverMysql = "mysql" DriverPostgres = "postgres" )
Variables ¶
This section is empty.
Functions ¶
func DefaultLogger ¶
func DefaultLogger(logCfg *LoggerConfig) logger.Interface
func RegisterDriver ¶
func RegisterDriver(dType string, provider DatabaseProvider)
Types ¶
type DatabaseConfig ¶
type DatabaseConfig struct { Dialect string `yaml:"dialect"` DSN string `yaml:"dsn"` MaxIdle int `yaml:"max_idle"` MaxOpen int `yaml:"max_open"` MaxLifetime int `yaml:"max_lifetime"` ShowSQL bool `yaml:"show_sql"` Logger LoggerConfig `yaml:"logger"` }
DatabaseConfig db datasource
type DatabaseProvider ¶
type DatabaseProvider interface {
Connect(config *DatabaseConfig) (*gorm.DB, error)
}
type Datasource ¶
type Datasource struct {
Databases []*DatabaseConfig `yaml:"databases,flow"`
}
Click to show internal directories.
Click to hide internal directories.