Documentation ¶
Index ¶
- func Close()
- func Deregister()
- func DeregisterByKey(key string)
- func GetDB() *gorm.DB
- func GetDBByKey(key string) *gorm.DB
- func MockDB(config *Config) (*sql.DB, sqlmock.Sqlmock)
- func MockDBByKey(config *Config, key string) (*sql.DB, sqlmock.Sqlmock)
- func Register(config *Config)
- func RegisterByKey(config *Config, key string)
- func SetLogger(db *gorm.DB, logger logger.Interface)
- type Config
- type ConfigOption
- type ConnectionConfig
- type Model
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MockDBByKey ¶
MockDBByKey mock DB by key
func RegisterByKey ¶
RegisterByKey register examples by key
Types ¶
type Config ¶
type Config struct { // connection string Connection *ConnectionConfig // the maximum number of open connections to the database MaxOpenConns int // the maximum number of connections in the idle connection pool MaxIdleConns int // the maximum amount of time a connection may be reused in second ConnMaxLifetime time.Duration // log level LogLevel logger.LogLevel // TablePrefix table prefix TablePrefix string // SingularTable enable singular table names SingularTable bool }
Config mysql configuration
type ConfigOption ¶
type ConfigOption interface {
// contains filtered or unexported methods
}
ConfigOption config option
func WithConnMaxLifetime ¶
func WithConnMaxLifetime(connMaxLifetime time.Duration) ConfigOption
WithConnMaxLifetime new connMaxLifetime option
func WithMaxIdleConns ¶
func WithMaxIdleConns(maxIdleConns int) ConfigOption
WithMaxIdleConns new maxIdleConns option
func WithMaxOpenConns ¶
func WithMaxOpenConns(maxOpenConns int) ConfigOption
WithMaxOpenConns new maxOpenConns option
func WithSingularTable ¶ added in v1.1.0
func WithSingularTable(singularTable bool) ConfigOption
WithSingularTable new singularTable option
func WithTablePrefix ¶ added in v1.1.0
func WithTablePrefix(tablePrefix string) ConfigOption
WithTablePrefix new tablePrefix option
Click to show internal directories.
Click to hide internal directories.