Documentation ¶
Index ¶
- Constants
- func ParseSqlResult(input any, output any) error
- func ParseSqlResultWithColumn(input any, output any, columnName string) error
- type CheckExistExecuteParams
- type CheckHasOnlyOneExecuteParams
- type Conditions
- func (conditions *Conditions) AddCondition(query string, args ...any) *Conditions
- func (conditions *Conditions) And() string
- func (conditions *Conditions) Args() []any
- func (conditions *Conditions) Equal(columnName string, arg any) *Conditions
- func (conditions *Conditions) GreaterThan(columnName string, arg any) *Conditions
- func (conditions *Conditions) GreaterThanAndEqual(columnName string, arg any) *Conditions
- func (conditions *Conditions) In(columnName string, arg any) *Conditions
- func (conditions *Conditions) LessThan(columnName string, arg any) *Conditions
- func (conditions *Conditions) LessThanAndEqual(columnName string, arg any) *Conditions
- func (conditions *Conditions) Like(columnName string, arg string) *Conditions
- func (conditions *Conditions) Not(columnName string, arg any) *Conditions
- func (conditions *Conditions) NotIn(columnName string, arg any) *Conditions
- func (conditions *Conditions) Queries() []string
- type CountExecuteParams
- type DeleteExecuteParams
- type InsertBatchExecuteParams
- type InsertExecuteParams
- type QueryExecuteParams
- type QueryOneExecuteParams
- type Result
- func (result Result) ColumnValueBool(columnName string) bool
- func (result Result) ColumnValueFloat32(columnName string) float32
- func (result Result) ColumnValueFloat64(columnName string) float64
- func (result Result) ColumnValueInt(columnName string) int
- func (result Result) ColumnValueInt16(columnName string) int16
- func (result Result) ColumnValueInt32(columnName string) int32
- func (result Result) ColumnValueInt64(columnName string) int64
- func (result Result) ColumnValueInt8(columnName string) int8
- func (result Result) ColumnValueString(columnName string) string
- func (result Result) ColumnValueStringAsTime(columnName string) time.Time
- func (result Result) ColumnValueUint(columnName string) uint
- func (result Result) ColumnValueUint16(columnName string) uint16
- func (result Result) ColumnValueUint32(columnName string) uint32
- func (result Result) ColumnValueUint64(columnName string) uint64
- func (result Result) ColumnValueUint8(columnName string) uint8
- type TableRow
- type UpdateExecuteParams
Constants ¶
const CountTpl = `
SELECT
COUNT(*)
FROM
{{ .table_name }}
WHERE
{{ range .queries }} {{ . }} AND {{ end }} 1 = 1
`
const DeleteTpl = `
DELETE FROM
{{ .table_name }}
WHERE
{{ range .queries }} {{ . }} AND {{ end }} 1 = 1
`
const InsertTpl = `` /* 289-byte string literal not displayed */
const QueryTpl = `` /* 318-byte string literal not displayed */
const UpdateTpl = `
UPDATE
{{ .table_name }}
SET
{{ .set_list | join ", " }}
WHERE
{{ range .queries }} {{ . }} AND {{ end }} 1 = 1
`
Variables ¶
This section is empty.
Functions ¶
func ParseSqlResult ¶
ParseSqlResult 解析查询结果 参数: - input: sql.Result或者[]sql.Result类型的查询结果 - output: 接收查询结果的指针,如果是结构,需要使用sqlresult tag标注字段 返回值: - 错误
Types ¶
type CheckExistExecuteParams ¶
type CheckExistExecuteParams struct { TableName string *Conditions Values []any }
CheckExistExecuteParams 存在性校验参数
type CheckHasOnlyOneExecuteParams ¶
type CheckHasOnlyOneExecuteParams struct { TableName string *Conditions }
CheckHasOnlyOneExecuteParams 唯一性校验参数
type Conditions ¶
type Conditions struct {
// contains filtered or unexported fields
}
Conditions 数据库条件
func (*Conditions) AddCondition ¶
func (conditions *Conditions) AddCondition(query string, args ...any) *Conditions
AddCondition 添加条件 参数: - query: 条件语句,如: name LIKE ? AND age = ? - args: 预编译值,如: foo, 10 返回值: - 数据库条件
func (*Conditions) And ¶ added in v0.11.3
func (conditions *Conditions) And() string
And 获取构造的AND条件语句 参数: 无 返回值: - 构造的AND条件语句
func (*Conditions) Args ¶ added in v0.11.0
func (conditions *Conditions) Args() []any
Args 获取所有查询条件值 参数: 无 返回值: - 查询条件值
func (*Conditions) Equal ¶
func (conditions *Conditions) Equal(columnName string, arg any) *Conditions
Equal 添加相等条件 参数: - columnName: 列名 - arg: 列值 返回值: - 数据库条件
func (*Conditions) GreaterThan ¶
func (conditions *Conditions) GreaterThan(columnName string, arg any) *Conditions
GreaterThan 添加大于条件 参数: - columnName: 列名 - arg: 列值 返回值: - 数据库条件
func (*Conditions) GreaterThanAndEqual ¶
func (conditions *Conditions) GreaterThanAndEqual(columnName string, arg any) *Conditions
GreaterThanAndEqual 添加大于等于条件 参数: - columnName: 列名 - arg: 列值 返回值: - 数据库条件
func (*Conditions) In ¶
func (conditions *Conditions) In(columnName string, arg any) *Conditions
In 添加IN条件 参数: - columnName: 列名 - arg: 列值 返回值: - 数据库条件
func (*Conditions) LessThan ¶
func (conditions *Conditions) LessThan(columnName string, arg any) *Conditions
LessThan 添加小于条件 参数: - columnName: 列名 - arg: 列值 返回值: - 数据库条件
func (*Conditions) LessThanAndEqual ¶
func (conditions *Conditions) LessThanAndEqual(columnName string, arg any) *Conditions
LessThanAndEqual 添加小于等于条件 参数: - columnName: 列名 - arg: 列值 返回值: - 数据库条件
func (*Conditions) Like ¶
func (conditions *Conditions) Like(columnName string, arg string) *Conditions
Like 添加LIKE条件 参数: - columnName: 列名 - arg: 列值 返回值: - 数据库条件
func (*Conditions) Not ¶
func (conditions *Conditions) Not(columnName string, arg any) *Conditions
Not 添加不相等条件 参数: - columnName: 列名 - arg: 列值 返回值: - 数据库条件
func (*Conditions) NotIn ¶
func (conditions *Conditions) NotIn(columnName string, arg any) *Conditions
NotIn 添加NOT IN条件 参数: - columnName: 列名 - arg: 列值 返回值: - 数据库条件
func (*Conditions) Queries ¶ added in v0.11.0
func (conditions *Conditions) Queries() []string
Queries 获取所有查询条件语句 参数: 无 返回值: - 查询条件
type CountExecuteParams ¶
type CountExecuteParams struct { TableName string *Conditions }
CountExecuteParams 计数参数
type DeleteExecuteParams ¶
type DeleteExecuteParams struct { TableName string *Conditions }
DeleteExecuteParams 删除参数
type InsertBatchExecuteParams ¶
InsertBatchExecuteParams 批量插入参数
type InsertExecuteParams ¶
InsertExecuteParams 插入参数
type QueryExecuteParams ¶
type QueryExecuteParams struct { TableName string SelectClauses []string *Conditions OrderBy string PageNo int PageSize int }
QueryExecuteParams 查询参数
type QueryOneExecuteParams ¶
type QueryOneExecuteParams struct { TableName string SelectClauses []string *Conditions }
QueryOneExecuteParams 单查询参数
type Result ¶
Result 查询结果
func (Result) ColumnValueBool ¶
ColumnValueBool 以bool类型获取列值 参数: - columnName: 列名 返回值: - bool类型的列值
func (Result) ColumnValueFloat32 ¶
ColumnValueFloat32 以float32类型获取列值 参数: - columnName: 列名 返回值: - float32类型的列值
func (Result) ColumnValueFloat64 ¶
ColumnValueFloat64 以float64类型获取列值 参数: - columnName: 列名 返回值: - float64类型的列值
func (Result) ColumnValueInt ¶
ColumnValueInt 以int类型获取列值 参数: - columnName: 列名 返回值: - int类型的列值
func (Result) ColumnValueInt16 ¶
ColumnValueInt16 以int16类型获取列值 参数: - columnName: 列名 返回值: - int16类型的列值
func (Result) ColumnValueInt32 ¶
ColumnValueInt32 以int32类型获取列值 参数: - columnName: 列名 返回值: - int32类型的列值
func (Result) ColumnValueInt64 ¶
ColumnValueInt64 以int64类型获取列值 参数: - columnName: 列名 返回值: - int64类型的列值
func (Result) ColumnValueInt8 ¶
ColumnValueInt8 以int8类型获取列值 参数: - columnName: 列名 返回值: - int8类型的列值
func (Result) ColumnValueString ¶
ColumnValueString 以string类型获取列值 参数: - columnName: 列名 返回值: - string类型的列值
func (Result) ColumnValueStringAsTime ¶
ColumnValueStringAsTime 将string类型的列值转化为time.Time 参数: - columnName: 列名 返回值: - 转换为time.Time的列值
func (Result) ColumnValueUint ¶
ColumnValueUint 以uint类型获取列值 参数: - columnName: 列名 返回值: - uint类型的列值
func (Result) ColumnValueUint16 ¶
ColumnValueUint16 以uint16类型获取列值 参数: - columnName: 列名 返回值: - uint16类型的列值
func (Result) ColumnValueUint32 ¶
ColumnValueUint32 以uint32类型获取列值 参数: - columnName: 列名 返回值: - uint32类型的列值
func (Result) ColumnValueUint64 ¶
ColumnValueUint64 以uint64类型获取列值 参数: - columnName: 列名 返回值: - uint64类型的列值
func (Result) ColumnValueUint8 ¶
ColumnValueUint8 以uint8类型获取列值 参数: - columnName: 列名 返回值: - uint8类型的列值
type TableRow ¶
type TableRow struct {
// contains filtered or unexported fields
}
TableRow 数据库表行
type UpdateExecuteParams ¶
type UpdateExecuteParams struct { TableName string *TableRow *Conditions }
UpdateExecuteParams 更新参数