Documentation
¶
Overview ¶
Mysql
Index ¶
- func ExtendParse(where Extend, extendField string) (whereSQL string, vals []any, err error)
- func OrderParse(order Order, fields ...string) (orderSQL string, err error)
- func WhereBuild(where map[string]any) (whereSQL string, vals []any, err error)
- func WhereParse(where Where, fields ...string) (whereSQL string, vals []any, err error)
- type Extend
- type MySQL
- type NullType
- type Order
- type Search
- func (search *Search) ExtendParse(extendField string) (whereSQL string, vals []any, err error)
- func (search *Search) LikeParse(keyword string, fields ...string) (likeSQL string)
- func (search *Search) OrderParse(fields ...string) (orderSQL string, err error)
- func (search *Search) WhereParse(fields ...string) (whereSQL string, vals []any, err error)
- type Where
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtendParse ¶
自定义where条件解析逻辑
func OrderParse ¶
自定义order条件解析逻辑
func WhereBuild ¶
sql build where
Types ¶
type MySQL ¶
type MySQL struct { HostName string `mapstructure:"HostName"` // 服务器地址 HostPort string `mapstructure:"HostPort"` // 端口 DataBase string `mapstructure:"DataBase"` // 数据库名 UserName string `mapstructure:"UserName"` // 用户名 PassWord string `mapstructure:"PassWord"` // 密码 Charset string `mapstructure:"Charset"` // 数据库编码默认采用utf8 Prefix string `mapstructure:"Prefix"` // 数据库表前缀 Timeout int `mapstructure:"Timeout"` // 设置最大打开的连接数,默认值为0表示不限制 MaxOpenConns int `mapstructure:"MaxOpenConns"` // 设置最大打开的连接数,默认值为0表示不限制 MaxIdleConns int `mapstructure:"MaxIdleConns"` // 连接池里面允许Idel的最大连接数 ConnMaxLifetime int `mapstructure:"ConnMaxLifetime"` // 设置一个连接的最长生命周期 LogLevel int `mapstructure:"LogLevel"` // SQL日志级别(Silent:1, Error:2, Warn:3, Info:4) // contains filtered or unexported fields }
MySQL配置
func (*MySQL) Connect ¶
SetMaxOpenConns: 设置最大打开的连接数,默认值为0表示不限制。控制应用于数据库建立连接的数量,避免过多连接压垮数据库。 SetMaxIdleConns: 连接池里面允许Idel(空闲)的最大连接数, 这些Idel的连接 就是并发时可以同时获取的连接,也是用完后放回池里面的互用的连接, 从而提升性能。 SetConnMaxLifetime: 设置一个连接的最长生命周期,因为数据库本身对连接有一个超时时间的设置,如果超时时间到了数据库会单方面断掉连接,此时再用连接池内的连接进行访问就会出错, 因此这个值往往要小于数据库本身的连接超时时间
type NullType ¶
type NullType byte
const ( // IsNull the same as `is null` IsNull NullType // IsNotNull the same as `is not null` IsNotNull )
type Search ¶
搜索结构
func (*Search) ExtendParse ¶
自定义where条件解析逻辑
func (*Search) OrderParse ¶
自定义order条件解析逻辑
Click to show internal directories.
Click to hide internal directories.