Documentation ¶
Index ¶
- Variables
- func CreateDatabaseIfNotExists(db *gorm.DB, database string) error
- func GetDB() (*gorm.DB, error)
- func MustSetUp(config *Config, logConfig *LogConfig)
- func NewLogger(logConfig *LogConfig) logger.Interface
- func SetUp(config *Config, logConfig *LogConfig) (err error)
- func StringToLevel(str string) (level logger.LogLevel, err error)
- type Config
- type DsnConfig
- type LogConfig
- type PoolConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var (
NotSetupError = errorKit.New("Haven’t been set up correctly")
)
Functions ¶
func CreateDatabaseIfNotExists ¶
CreateDatabaseIfNotExists 自动创建数据库
在 Go 项目中优雅的使用 gorm v2
https://segmentfault.com/a/1190000039097157
Types ¶
type Config ¶
type Config struct { DsnConfig Pool PoolConfig `json:"pool" yaml:"pool"` }
type DsnConfig ¶
type DsnConfig struct { UserName string `json:"userName" yaml:"userName"` Password string `json:"password" yaml:"password"` // Host e.g."127.0.0.1:3306" Host string `json:"host" yaml:"host"` DBName string `json:"dbName" yaml:"dbName"` }
func (*DsnConfig) GetDsnString ¶
Click to show internal directories.
Click to hide internal directories.