Documentation ¶
Index ¶
- type DB
- type Option
- func ConfigOption(key string) (option *Option, err error)
- func NewOption() *Option
- func SetConnMaxLifetime(l string) *Option
- func SetDisableAutomaticPing(l bool) *Option
- func SetDisableForeignKeyConstraintWhenMigrating(l bool) *Option
- func SetDryRun(l bool) *Option
- func SetInstanceName(l string) *Option
- func SetLogger(l baselogger.GormLogger) *Option
- func SetMaxIdleConns(l int) *Option
- func SetMaxOpenConns(l int) *Option
- func SetPrepareStmt(l bool) *Option
- func SetSingularTable(l bool) *Option
- func SetSkipDefaultTransaction(l bool) *Option
- func SetSlowThreshold(l string) *Option
- func SetTablePrefix(l string) *Option
- func (c *Option) MergeOption(opts ...*Option) *Option
- func (c *Option) SetConnMaxLifetime(l string) *Option
- func (c *Option) SetDisableAutomaticPing(l bool) *Option
- func (c *Option) SetDisableForeignKeyConstraintWhenMigrating(l bool) *Option
- func (c *Option) SetDryRun(l bool) *Option
- func (c *Option) SetInstanceName(l string) *Option
- func (c *Option) SetLogger(l baselogger.GormLogger) *Option
- func (c *Option) SetMaxIdleConns(l int) *Option
- func (c *Option) SetMaxOpenConns(l int) *Option
- func (c *Option) SetPrepareStmt(l bool) *Option
- func (c *Option) SetSingularTable(l bool) *Option
- func (c *Option) SetSkipDefaultTransaction(l bool) *Option
- func (c *Option) SetSlowThreshold(l string) *Option
- func (c *Option) SetTablePrefix(l string) *Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option struct { InstanceName string // 最大空闲连接数 MaxIdleConns int // 最大活动连接数 MaxOpenConns int // 连接的最大存活时间 ConnMaxLifetime string // 生成 SQL 但不执行,可以用于准备或测试生成的 SQL DryRun bool // PreparedStmt 在执行任何 SQL 时都会创建一个 prepared statement 并将其缓存,以提高后续的效率, PrepareStmt bool // 在完成初始化后,GORM 会自动 ping 数据库以检查数据库的可用性,若要禁用该特性,可将其设置为 true DisableAutomaticPing bool // 在 AutoMigrate 或 CreateTable 时,GORM 会自动创建外键约束,若要禁用该特性,可将其设置为 true DisableForeignKeyConstraintWhenMigrating bool // 慢日志阈值 SlowThreshold string SkipDefaultTransaction bool Logger baselogger.GormLogger TablePrefix string SingularTable bool }
func SetConnMaxLifetime ¶
func SetDisableAutomaticPing ¶
func SetInstanceName ¶
func SetLogger ¶
func SetLogger(l baselogger.GormLogger) *Option
func SetMaxIdleConns ¶
func SetMaxOpenConns ¶
func SetPrepareStmt ¶
func SetSingularTable ¶
func SetSlowThreshold ¶
func SetTablePrefix ¶
func (*Option) MergeOption ¶
func (*Option) SetConnMaxLifetime ¶
func (*Option) SetDisableAutomaticPing ¶
func (*Option) SetDisableForeignKeyConstraintWhenMigrating ¶
func (*Option) SetInstanceName ¶
func (*Option) SetLogger ¶
func (c *Option) SetLogger(l baselogger.GormLogger) *Option
func (*Option) SetMaxIdleConns ¶
func (*Option) SetMaxOpenConns ¶
func (*Option) SetPrepareStmt ¶
func (*Option) SetSingularTable ¶
func (*Option) SetSkipDefaultTransaction ¶
func (*Option) SetSlowThreshold ¶
func (*Option) SetTablePrefix ¶
Click to show internal directories.
Click to hide internal directories.