Documentation ¶
Index ¶
- Constants
- func InString(arr []string) []string
- type DatabaseConf
- type Db
- type FilterEmpty
- func (c *FilterEmpty) DateTime(where string, value string, location *time.Location) *FilterEmpty
- func (c *FilterEmpty) Float64(where string, value float64) *FilterEmpty
- func (c *FilterEmpty) Int64(where string, value int64) *FilterEmpty
- func (c *FilterEmpty) Pagination(p *Pagination) *FilterEmpty
- func (c *FilterEmpty) RangeTime(where string, rangeTime *RangeTimeParam, location *time.Location) *FilterEmpty
- func (c *FilterEmpty) SetUpdateOpt() *FilterEmpty
- func (c *FilterEmpty) String(where string, value string) *FilterEmpty
- type Pagination
- type RangeTimeParam
Constants ¶
View Source
const ( AndWhere = "AND" OrWhere = "OR" LeftJoin = "LEFT JOIN" InnerJoin = "INNER JOIN" RightJoin = "RIGHT JOIN" )
View Source
const (
OptUpdate = 1 // 更新操作
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DatabaseConf ¶
type DatabaseConf struct { Drive string // 驱动 User string // 用户名 Pass string // 密码 Dbname string // 库名 Network string // 网络 Server string // 地址 Port int // 端口 ConnMaxLifeTime time.Duration // 最大连接周期 MaxOpenConn int // 设置最大连接数 ConnMaxIdleTime time.Duration // 最大空闲连接时间 MaxIdleConn int // 最大空闲连接数 Params map[string]interface{} // 连接参数 }
DatabaseConf 数据库配置
type Db ¶
type Db interface { // Table 设置表名 Table("user") | Table("user a") Table(tableName string) Db // Insert 插入数据库 Insert() (int64, error) // Delete 删除数据 Delete() (int64, error) // Update 更新 Update() (int64, error) // QueryRow 单条查询 QueryRow(rowFn func(row *sql.Row)) // Count 总数 Count() int64 // ColumnInt64 列整数 ColumnInt64() []int64 // ColumnString 列字符串 ColumnString() []string // Query 多条查询 Query(rowsFn func(rows *sql.Rows)) // SqlExec [插入|更新|删除] 返回[插入ID|影响行数] SqlExec(s string, args []any) (sql.Result, error) // SqlQuery 查询多条数据 SqlQuery(s string, args []any, rowsFn func(rows *sql.Rows)) // SqlQueryRow 查询单挑数据 SqlQueryRow(s string, args []any, rowFn func(row *sql.Row)) // Field 设置字段名 Field("a", "b", "c") Field(field ...string) Db // Value 设置值[插入|更新] Value("?", "?", "id=90") Value(val ...string) Db // Args 设置替换字符值[插入|更新|查询|删除] Args(100, "0,1") Args(args ...any) Db // Where 条件语句 Where(opt string, str string, arg ...any) Db // AndWhere 条件语句 AndWhere(str string, arg ...any) Db // OrWhere 并且条件语句 OrWhere(str string, arg ...any) Db // Join 连接操作 Join(opt, name, on string) Db // LeftJoin 左连接 LeftJoin(str, on string) Db // InnerJoin 内连接 InnerJoin(str, on string) Db // RightJoin 右连接 RightJoin(str, on string) Db // OrderBy 排序 OrderBy(orderBy ...string) Db // GroupBy 分组 GroupBy(groupBy ...string) Db // OffsetLimit 限制行数 OffsetLimit(offset, limit int64) Db // GetTx 获取Tx GetTx() *sql.Tx // GetDb 获取Db GetDb() *sql.DB }
type FilterEmpty ¶ added in v1.1.0
type FilterEmpty struct { Db Db // 模型Db // contains filtered or unexported fields }
func NewFilterEmpty ¶ added in v1.1.0
func NewFilterEmpty(db Db) *FilterEmpty
func (*FilterEmpty) DateTime ¶ added in v1.1.0
func (c *FilterEmpty) DateTime(where string, value string, location *time.Location) *FilterEmpty
DateTime 过滤时间转时间戳
func (*FilterEmpty) Float64 ¶ added in v1.1.0
func (c *FilterEmpty) Float64(where string, value float64) *FilterEmpty
Float64 过滤浮点型
func (*FilterEmpty) Int64 ¶ added in v1.1.0
func (c *FilterEmpty) Int64(where string, value int64) *FilterEmpty
Int64 过滤整形
func (*FilterEmpty) Pagination ¶ added in v1.1.0
func (c *FilterEmpty) Pagination(p *Pagination) *FilterEmpty
Pagination 分页设置
func (*FilterEmpty) RangeTime ¶ added in v1.1.0
func (c *FilterEmpty) RangeTime(where string, rangeTime *RangeTimeParam, location *time.Location) *FilterEmpty
RangeTime 是否时间范围
func (*FilterEmpty) SetUpdateOpt ¶ added in v1.1.0
func (c *FilterEmpty) SetUpdateOpt() *FilterEmpty
func (*FilterEmpty) String ¶ added in v1.1.0
func (c *FilterEmpty) String(where string, value string) *FilterEmpty
String 过滤字符串
type Pagination ¶ added in v1.1.0
type Pagination struct { SortBy string `json:"sortBy"` // 排序字段 Descending bool `json:"descending"` // 是否降序排序 Page int64 `json:"page"` // 当前页数 RowsPerPage int64 `json:"rowsPerPage"` // 每页显示条数 }
Pagination 分页
type RangeTimeParam ¶ added in v1.1.0
RangeTimeParam 时间范围参数
Click to show internal directories.
Click to hide internal directories.