Documentation
¶
Index ¶
- Constants
- func AutoMigrate(conf Config, opts ...DialOptionFunc) error
- func GetDbByConf(conf Config, opts ...DialOptionFunc) *gorm.DB
- func GetDbByModel(m SqlModel, opts ...DialOptionFunc) *gorm.DB
- func GormIsErrRecordNotFound(err error) (bool, error)
- func NewClient(conf Config, opts ...DialOptionFunc) *client
- func NewGormLogger(opts ...GormLoggerOption) *gormLogger
- func PrePing(conf Config, opts ...DialOptionFunc) error
- func RegisterSqlModel(conf Config, ms ...SqlModel)deprecated
- func RegisterSqlModelWithConf(conf Config, ms ...SqlModel) error
- type Config
- type DbType
- type DialOption
- type DialOptionFunc
- type GormLoggerOption
- type MysqlConfig
- type MysqlDsn
- type SqlModel
- type SqliteConfig
Constants ¶
View Source
const ( DbMysql = iota DbSqlite )
Variables ¶
This section is empty.
Functions ¶
func AutoMigrate ¶
func AutoMigrate(conf Config, opts ...DialOptionFunc) error
func GetDbByConf ¶
func GetDbByConf(conf Config, opts ...DialOptionFunc) *gorm.DB
func GetDbByModel ¶
func GetDbByModel(m SqlModel, opts ...DialOptionFunc) *gorm.DB
func GormIsErrRecordNotFound ¶
func NewClient ¶
func NewClient(conf Config, opts ...DialOptionFunc) *client
func NewGormLogger ¶
func NewGormLogger(opts ...GormLoggerOption) *gormLogger
func PrePing ¶ added in v1.1.25
func PrePing(conf Config, opts ...DialOptionFunc) error
func RegisterSqlModel
deprecated
Types ¶
type DialOption ¶ added in v1.1.25
type DialOptionFunc ¶ added in v1.1.25
type DialOptionFunc func(opt *DialOption)
func WithDialIgnoreNotFound ¶ added in v1.1.25
func WithDialIgnoreNotFound() DialOptionFunc
func WithDialThreshold ¶ added in v1.1.25
func WithDialThreshold(threshold time.Duration) DialOptionFunc
func WithLogPrefix ¶ added in v1.1.25
func WithLogPrefix(prefix string) DialOptionFunc
type GormLoggerOption ¶
type GormLoggerOption func(g *gormLogger)
func WithIgnoreRecordNotFound ¶
func WithIgnoreRecordNotFound() GormLoggerOption
func WithPrefix ¶
func WithPrefix(prefix string) GormLoggerOption
func WithSlowThreshold ¶
func WithSlowThreshold(dur time.Duration) GormLoggerOption
type MysqlConfig ¶
func (*MysqlConfig) DialGorm ¶
func (m *MysqlConfig) DialGorm(opts ...DialOptionFunc) (*gorm.DB, error)
func (*MysqlConfig) GetDBType ¶
func (m *MysqlConfig) GetDBType() DbType
func (*MysqlConfig) GetService ¶
func (m *MysqlConfig) GetService() string
func (*MysqlConfig) GetUid ¶
func (m *MysqlConfig) GetUid() string
func (*MysqlConfig) TrimSpace ¶
func (m *MysqlConfig) TrimSpace()
func (*MysqlConfig) Validate ¶
func (m *MysqlConfig) Validate() error
type SqliteConfig ¶
type SqliteConfig struct {
DbFile string
}
func (*SqliteConfig) DialGorm ¶
func (s *SqliteConfig) DialGorm(opts ...DialOptionFunc) (*gorm.DB, error)
func (*SqliteConfig) GetDBType ¶
func (s *SqliteConfig) GetDBType() DbType
func (*SqliteConfig) GetService ¶
func (s *SqliteConfig) GetService() string
func (*SqliteConfig) GetUid ¶
func (s *SqliteConfig) GetUid() string
Click to show internal directories.
Click to hide internal directories.