Documentation
¶
Index ¶
- Constants
- Variables
- func CountSQL(statement *Statement) (sql string)
- func DeleteSQL(statement *Statement) string
- func FindSQL(statement *Statement) (sql string)
- func GetSQLWithParams(sql string, params []interface{}) string
- func InsertSQL(statement *Statement) string
- func ReplaceSQL(statement *Statement) string
- func SetLocation(l *time.Location)
- func UpdateSQL(statement *Statement) string
- type Join
- type NullBool
- type NullFloat
- type NullInt
- type NullString
- type NullTime
- type NullUint
- type Query
- func (q *Query) Count(ctx context.Context, s *Statement) (uint64, error)
- func (q *Query) Find(ctx context.Context, s *Statement, querySQL string, params []interface{}) (result map[string]interface{}, err error)
- func (q *Query) FindAll(ctx context.Context, s *Statement, querySQL string, params []interface{}) (result []map[string]interface{}, err error)
- func (q *Query) InsertToCK(ctx context.Context, desc string, batch bool, retryTime int, table string, ...) ([]map[string]interface{}, map[int]error, error)
- func (q *Query) Query(ctx context.Context) (interface{}, *proto.Detail, bool, error)
- func (q *Query) SetParams(req *filter.Request, property *obj.Property, addr *util.DBAddress, ...) error
- func (q *Query) Transaction(ctx context.Context, fn func(c *Query) error) error
- type Statement
- func (s *Statement) GetOrder() string
- func (s *Statement) GetParams() []interface{}
- func (s *Statement) GetWhere() string
- func (s *Statement) Group(group []string) *Statement
- func (s *Statement) Having(dbType int, having map[string]interface{}) *Statement
- func (s *Statement) Join(joins []*Join) *Statement
- func (s *Statement) Limit(limit int) *Statement
- func (s *Statement) Order(orders []string) *Statement
- func (s *Statement) SetColumn(column []string) *Statement
- func (s *Statement) SetDBType(typ int) *Statement
- func (s *Statement) SetMaps(attributeArr []map[string]interface{}) *Statement
- func (s *Statement) SetTable(table, alias string) *Statement
- func (s *Statement) UpdateMap(attributes map[string]interface{}) *Statement
- func (s *Statement) Where(dbType int, where map[string]interface{}) *Statement
Constants ¶
View Source
const ( TypeInt = iota TypeInt8 TypeInt16 TypeInt32 TypeInt64 TypeUInt TypeUInt8 TypeUInt16 TypeUInt32 TypeUInt64 TypeFloat32 TypeFloat64 TypeString TypeTime TypeBytes TypeJSON )
Variables ¶
View Source
var ClickHouseTypeMap = map[string]int8{ "Int": TypeInt, "Int8": TypeInt8, "Int16": TypeInt16, "Int32": TypeInt32, "Int64": TypeInt64, "UInt": TypeUInt, "UInt8": TypeUInt8, "UInt16": TypeUInt16, "UInt32": TypeUInt32, "UInt64": TypeUInt64, "Float": TypeFloat32, "Float32": TypeFloat32, "Float64": TypeFloat64, "Decimal": TypeFloat64, "String": TypeString, "FixedString": TypeString, "UUID": TypeString, "DateTime": TypeTime, "DateTime64": TypeTime, "Date": TypeTime, }
View Source
var MySQLTypeMap = map[string]int8{ "INT": TypeInt, "TINYINT": TypeInt8, "SMALLINT": TypeInt16, "MEDIUMINT": TypeInt32, "BIGINT": TypeInt64, "BIT": TypeBytes, "FLOAT": TypeFloat32, "DOUBLE": TypeFloat64, "DECIMAL": TypeFloat64, "VARCHAR": TypeString, "CHAR": TypeString, "TEXT": TypeString, "BLOB": TypeBytes, "BINARY": TypeBytes, "VARBINARY": TypeBytes, "TIME": TypeString, "DATE": TypeTime, "DATETIME": TypeTime, "TIMESTAMP": TypeTime, "JSON": TypeJSON, }
Functions ¶
func GetSQLWithParams ¶
func SetLocation ¶
SetLocation 慎重使用,此处影响的是全局的 NullTime 时间 logic 的时区
Types ¶
type Join ¶
type Join struct {
Type string `json:"type,omitempty"`
Table string `json:"table,omitempty"`
Using []string `json:"using,omitempty"`
On map[string]string `json:"on,omitempty"`
}
Join MySQL 表 JOIN
type NullString ¶
NullString 数据库 varchar NULL 类型
func (*NullString) Scan ¶
func (ns *NullString) Scan(value interface{}) error
Scan NullString 类型实现 mysql 引擎查询赋值接口
type Query ¶
type Query struct {
OP string
Table, Alias string
Where, Having map[string]interface{}
Column []string
Group []string
Order []string
Join []*Join
Data map[string]interface{}
Datas []map[string]interface{}
Page int
Size int
From uint64
SQL string
Params []interface{}
// 建表用
Shard []string
IfNotExists bool
DB *obj.TblDB
Addr *util.DBAddress
TblTable *obj.TblTable
TransInfo *obj.TransInfo
TimeLog *log.TimeLog
// contains filtered or unexported fields
}
func (*Query) Find ¶
func (q *Query) Find(ctx context.Context, s *Statement, querySQL string, params []interface{}) (result map[string]interface{}, err error)
Find 查询符合要求的一条数据,返回结果为 map[string]string
func (*Query) FindAll ¶
func (q *Query) FindAll(ctx context.Context, s *Statement, querySQL string, params []interface{}) (result []map[string]interface{}, err error)
FindAll 查询符合要求的所有数据,返回 []map[string]string 格式数据
func (*Query) InsertToCK ¶
func (q *Query) InsertToCK(ctx context.Context, desc string, batch bool, retryTime int, table string, datas []map[string]interface{}) ([]map[string]interface{}, map[int]error, error)
InsertToCK clickhouse 批量插入,(必须通过事务生成批量语句,然后提交)
type Statement ¶
type Statement struct {
// contains filtered or unexported fields
}
Statement 查询语句结构体
Source Files
¶
Click to show internal directories.
Click to hide internal directories.