Documentation ¶
Index ¶
- func New(config map[string]interface{}) (interface{}, error)
- type Client
- func (c *Client) Init() error
- func (c *Client) LogLevel() logger.LogLevel
- func (c *Client) SetAllowGlobalUpdate(v bool)
- func (c *Client) SetDefaultStringSize(v uint)
- func (c *Client) SetDialect(v IFuncDialect)
- func (c *Client) SetDisableAutomaticPing(v bool)
- func (c *Client) SetDisableDatetimePrecision(v bool)
- func (c *Client) SetDisableForeignKeyConstraintWhenMigrating(v bool)
- func (c *Client) SetDontSupportRenameColumn(v bool)
- func (c *Client) SetDontSupportRenameIndex(v bool)
- func (c *Client) SetDriver(driver string)
- func (c *Client) SetDryRun(v bool)
- func (c *Client) SetDsn(dsn string)
- func (c *Client) SetLogLevel(v logger.LogLevel)
- func (c *Client) SetMaxConnTime(v string) error
- func (c *Client) SetMaxIdleConn(maxIdleConn int)
- func (c *Client) SetMaxOpenConn(maxOpenConn int)
- func (c *Client) SetPrepareStmt(v bool)
- func (c *Client) SetSingularTable(v bool)
- func (c *Client) SetSkipDefaultTransaction(v bool)
- func (c *Client) SetSkipInitializeWithVersion(v bool)
- func (c *Client) SetSlaves(v []interface{})
- func (c *Client) SetSlowLogTime(v string) error
- func (c *Client) SetSqlLog(sqlLog bool)
- func (c *Client) SetTablePrefix(v string)
- func (c *Client) SlowLogTime() time.Duration
- func (c *Client) SqlLog() bool
- type IFuncDialect
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
func (*Client) SetAllowGlobalUpdate ¶
启用全局 update/delete,查看 Session 获取详情
func (*Client) SetDefaultStringSize ¶
string 类型字段的默认长度
func (*Client) SetDisableAutomaticPing ¶
在完成初始化后,GORM 会自动 ping 数据库以检查数据库的可用性,若要禁用该特性,可将其设置为 true
func (*Client) SetDisableDatetimePrecision ¶
禁用 datetime 精度,MySQL 5.6 之前的数据库不支持
func (*Client) SetDisableForeignKeyConstraintWhenMigrating ¶
在 AutoMigrate 或 CreateTable 时,GORM 会自动创建外键约束,若要禁用该特性,可将其设置为 true,参考 迁移 获取详情。
func (*Client) SetDontSupportRenameColumn ¶
用 `change` 重命名列,MySQL 8 之前的数据库和 MariaDB 不支持重命名列
func (*Client) SetDontSupportRenameIndex ¶
重命名索引时采用删除并新建的方式,MySQL 5.7 之前的数据库和 MariaDB 不支持重命名索引
func (*Client) SetDsn ¶
SetDsn set master dsn, the dsn is driver specified, eg. dsn format for github.com/go-sql-driver/mysql is [username[:password]@][protocol[(address)]]/dbname[?param=value]
func (*Client) SetLogLevel ¶
func (*Client) SetMaxConnTime ¶
SetMaxConnTime set conn life time, default is 1h
func (*Client) SetMaxIdleConn ¶
SetMaxIdleConn set max idle conn, default is 5
func (*Client) SetMaxOpenConn ¶
SetMaxOpenConn set max open conn, default is 0
func (*Client) SetPrepareStmt ¶
SetPrepareStmt 执行任何 SQL 时都创建并缓存预编译语句,可以提高后续的调用速度
func (*Client) SetSkipDefaultTransaction ¶
SetSkipDefaultTransaction 对于写操作(创建、更新、删除),为了确保数据的完整性,GORM 会将它们封装在事务内运行。但这会降低性能,你可以在初始化时禁用这种方式
func (*Client) SetSkipInitializeWithVersion ¶
根据当前 MySQL 版本自动配置
func (*Client) SetSlowLogTime ¶
SetSlowTime set slow log time, default is 100ms
func (*Client) SetTablePrefix ¶
表名前缀,`User` 的表名应该是 v+`_user`