Documentation
¶
Index ¶
- func CreateDatabaseIfNotExists(driverName, dataSourceName, databaseName string, ops ...Option) error
- func GormComment(description string) string
- func NewConnection(config *Config, ops ...Option) (*gorm.DB, error)
- func NewDataSourceName(host, username, password, database string, ops ...Option) string
- func NewDataSourceNameForConfig(config *Config, ops ...Option) string
- func NewDataSourceNameForNoSelectDatabase(host, username, password string, ops ...Option) string
- type Config
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDatabaseIfNotExists ¶
func CreateDatabaseIfNotExists(driverName, dataSourceName, databaseName string, ops ...Option) error
CreateDatabaseIfNotExists If database not exists, then create it.
func GormComment ¶
GormComment get table comment for the description.
func NewConnection ¶
NewConnection create a new gorm db instance with the given options.
func NewDataSourceName ¶
NewDataSourceName initialize database of the data source name. If database parameter is empty, will not choose database, such as only open database connection.
func NewDataSourceNameForConfig ¶
NewDataSourceNameForConfig Get data source name for given options.
Types ¶
type Config ¶
type Config struct { Host string Username string Password string Database string MaxIdleConnections int MaxOpenConnections int MaxConnectionLifeTime time.Duration LogLevel int Logger logger.Interface DriverName connecter.DriverName }
Config defines config for database.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithCharset ¶
func WithLocation ¶
func WithParseTime ¶
Click to show internal directories.
Click to hide internal directories.