Documentation ¶
Index ¶
- Constants
- func NewSqlConn(driverName, server string, opt *Opt) (*sql.DB, error)
- type BatchError
- type Connection
- type Epr
- type Grammar
- type NullBool
- type NullDate
- type NullDateTime
- type NullFloat64
- type NullInt32
- type NullInt64
- type NullString
- type Nullable
- type Opt
- type QueryBuilder
- func (query *QueryBuilder) Between(column string, value1 interface{}, value2 interface{}) *QueryBuilder
- func (query *QueryBuilder) Count() (int64, error)
- func (query *QueryBuilder) Delete() (int64, error)
- func (query *QueryBuilder) DeleteSQL() string
- func (query *QueryBuilder) Distinct() *QueryBuilder
- func (query *QueryBuilder) Equal(column string, value interface{}) *QueryBuilder
- func (query *QueryBuilder) Exec(sql string, args ...interface{}) (int64, error)
- func (query *QueryBuilder) ExecSQL(sql string, args ...interface{}) string
- func (query *QueryBuilder) GroupBy(groups ...string) *QueryBuilder
- func (query *QueryBuilder) In(column string, value ...interface{}) *QueryBuilder
- func (query *QueryBuilder) InnerJoin(tablename string, on string) *QueryBuilder
- func (query *QueryBuilder) Insert(data interface{}) (int64, error)
- func (query *QueryBuilder) InsertSQL(data interface{}) string
- func (query *QueryBuilder) InsertUpdate(insert interface{}, update interface{}) (int64, error)
- func (query *QueryBuilder) InsertUpdateSQL(insert interface{}, update interface{}) string
- func (query *QueryBuilder) IsNULL(column string) *QueryBuilder
- func (query *QueryBuilder) IsNotNULL(column string) *QueryBuilder
- func (query *QueryBuilder) IsZero(v reflect.Value) bool
- func (query *QueryBuilder) Join(tablename string, on string) *QueryBuilder
- func (query *QueryBuilder) LeftJoin(tablename string, on string) *QueryBuilder
- func (query *QueryBuilder) Like(column string, value interface{}) *QueryBuilder
- func (query *QueryBuilder) Limit(limit int64) *QueryBuilder
- func (query *QueryBuilder) MultiInsert(datas ...interface{}) (int64, error)
- func (query *QueryBuilder) MultiInsertSQL(datas ...interface{}) string
- func (query *QueryBuilder) NotBetween(column string, value1 interface{}, value2 interface{}) *QueryBuilder
- func (query *QueryBuilder) NotEqual(column string, value interface{}) *QueryBuilder
- func (query *QueryBuilder) NotIn(column string, value ...interface{}) *QueryBuilder
- func (query *QueryBuilder) NotOrBetween(column string, value1 interface{}, value2 interface{}) *QueryBuilder
- func (query *QueryBuilder) Offset(offset int64) *QueryBuilder
- func (query *QueryBuilder) OrBetween(column string, value1 interface{}, value2 interface{}) *QueryBuilder
- func (query *QueryBuilder) OrEqual(column string, value interface{}) *QueryBuilder
- func (query *QueryBuilder) OrIn(column string, value ...interface{}) *QueryBuilder
- func (query *QueryBuilder) OrIsNULL(column string) *QueryBuilder
- func (query *QueryBuilder) OrIsNotNULL(column string) *QueryBuilder
- func (query *QueryBuilder) OrLike(column string, value interface{}) *QueryBuilder
- func (query *QueryBuilder) OrNotEqual(column string, value interface{}) *QueryBuilder
- func (query *QueryBuilder) OrNotIn(column string, value ...interface{}) *QueryBuilder
- func (query *QueryBuilder) OrWhere(column string, value ...interface{}) *QueryBuilder
- func (query *QueryBuilder) OrderBy(column string, direction string) *QueryBuilder
- func (query *QueryBuilder) QueryRow(sql string, args ...interface{}) *Row
- func (query *QueryBuilder) QueryRowSQL(sql string, args ...interface{}) string
- func (query *QueryBuilder) QueryRows(sql string, args ...interface{}) *Rows
- func (query *QueryBuilder) QueryRowsSQL(sql string, args ...interface{}) string
- func (query *QueryBuilder) Replace(datas ...interface{}) (int64, error)
- func (query *QueryBuilder) ReplaceSQL(datas ...interface{}) string
- func (query *QueryBuilder) RightJoin(tablename string, on string) *QueryBuilder
- func (query *QueryBuilder) Row() *Row
- func (query *QueryBuilder) RowSQL() string
- func (query *QueryBuilder) Rows() *Rows
- func (query *QueryBuilder) RowsSQL() string
- func (query *QueryBuilder) Select(columns ...string) *QueryBuilder
- func (query *QueryBuilder) Skip(offset int64) *QueryBuilder
- func (query *QueryBuilder) Table(tablename ...string) *QueryBuilder
- func (query *QueryBuilder) ToSql(method string) string
- func (query *QueryBuilder) Union(unions ...QueryBuilder) *QueryBuilder
- func (query *QueryBuilder) UnionAll(unions ...QueryBuilder) *QueryBuilder
- func (query *QueryBuilder) UnionLimit(limit int64) *QueryBuilder
- func (query *QueryBuilder) UnionOffset(offset int64) *QueryBuilder
- func (query *QueryBuilder) UnionOrderBy(column string, direction string) *QueryBuilder
- func (query *QueryBuilder) Update(data interface{}) (int64, error)
- func (query *QueryBuilder) UpdateSQL(data interface{}) string
- func (query *QueryBuilder) Where(column string, value ...interface{}) *QueryBuilder
- type QueryDb
- func (querydb *QueryDb) Begin() (*QueryTx, error)
- func (querydb *QueryDb) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (querydb *QueryDb) GetLastSql() Sql
- func (querydb *QueryDb) LastSql(query string, args ...interface{})
- func (querydb *QueryDb) NewQuery(ctx context.Context) *QueryBuilder
- func (querydb *QueryDb) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (querydb *QueryDb) SetTrace(t bool)
- type QueryTx
- func (querytx *QueryTx) Commit() error
- func (querytx *QueryTx) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (querytx *QueryTx) GetLastSql() Sql
- func (querytx *QueryTx) LastSql(query string, args ...interface{})
- func (querytx *QueryTx) NewQuery(ctx context.Context) *QueryBuilder
- func (querytx *QueryTx) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (querytx *QueryTx) Rollback() error
- type ResourceManager
- type Row
- type Rows
- type SharedCalls
- type SingleFlight
- type Sql
Constants ¶
const ( BETWEEN = "BETWEEN" NOTBETWEEN = "NOT BETWEEN" IN = "IN" NOTIN = "NOT IN" AND = "AND" OR = "OR" ISNULL = "IS NULL" ISNOTNULL = "IS NOT NULL" EQUAL = "=" NOTEQUAL = "!=" LIKE = "LIKE" JOIN = "JOIN" INNERJOIN = "INNER JOIN" LEFTJOIN = "LEFT JOIN" RIGHTJOIN = "RIGHT JOIN" UNION = "UNION" UNIONALL = "UNION ALL" DESC = "DESC" ASC = "ASC" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BatchError ¶
type BatchError struct {
// contains filtered or unexported fields
}
A BatchError is an error that can hold multiple errors.
func (*BatchError) Err ¶
func (be *BatchError) Err() error
Err returns an error that represents all errors.
type Connection ¶
type Connection interface { Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) NewQuery(ctx context.Context) *QueryBuilder GetLastSql() Sql LastSql(query string, args ...interface{}) }
Connection 链接
type Grammar ¶
type Grammar struct {
// contains filtered or unexported fields
}
Grammar sql 语法
func (Grammar) InsertUpdate ¶
type NullBool ¶
func NewNullBool ¶
func NewNullBool() NullBool
func (NullBool) MarshalJSON ¶
func (*NullBool) UnmarshalJSON ¶
type NullDate ¶
type NullDate struct {
sql.NullString
}
NullDate 空字符串
func NewNullDate ¶
func NewNullDate() NullDate
func (NullDate) MarshalJSON ¶
func (*NullDate) UnmarshalJSON ¶
type NullDateTime ¶
type NullDateTime struct {
sql.NullString
}
NullDate 空字符串
func NewDateTime ¶
func NewDateTime(s interface{}) NullDateTime
func NewNullDateTime ¶
func NewNullDateTime() NullDateTime
func (NullDateTime) IsEmpty ¶
func (ns NullDateTime) IsEmpty() bool
func (NullDateTime) IsValid ¶
func (ns NullDateTime) IsValid() bool
func (NullDateTime) MarshalJSON ¶
func (ns NullDateTime) MarshalJSON() ([]byte, error)
func (NullDateTime) Result ¶
func (ns NullDateTime) Result() interface{}
func (*NullDateTime) Scan ¶
func (nt *NullDateTime) Scan(value interface{}) error
func (*NullDateTime) UnmarshalJSON ¶
func (ns *NullDateTime) UnmarshalJSON(b []byte) error
type NullFloat64 ¶
type NullFloat64 struct{ sql.NullFloat64 }
func NewFloat64 ¶
func NewFloat64(f float64) NullFloat64
func NewNullFloat64 ¶
func NewNullFloat64() NullFloat64
func (NullFloat64) Convert ¶
func (n NullFloat64) Convert() string
func (NullFloat64) IsEmpty ¶
func (n NullFloat64) IsEmpty() bool
func (NullFloat64) IsValid ¶
func (n NullFloat64) IsValid() bool
func (NullFloat64) MarshalJSON ¶
func (nf NullFloat64) MarshalJSON() ([]byte, error)
func (NullFloat64) Result ¶
func (ns NullFloat64) Result() interface{}
func (*NullFloat64) UnmarshalJSON ¶
func (nf *NullFloat64) UnmarshalJSON(b []byte) error
type NullInt32 ¶
func NewNullInt32 ¶
func NewNullInt32() NullInt32
func (NullInt32) MarshalJSON ¶
func (*NullInt32) UnmarshalJSON ¶
type NullInt64 ¶
func NewNullInt64 ¶
func NewNullInt64() NullInt64
func (NullInt64) MarshalJSON ¶
func (*NullInt64) UnmarshalJSON ¶
type NullString ¶
type NullString struct {
sql.NullString
}
NullString 空字符串
func NewNullString ¶
func NewNullString() NullString
func NewString ¶
func NewString(s string) NullString
func (NullString) Convert ¶
func (n NullString) Convert() string
func (NullString) IsEmpty ¶
func (ns NullString) IsEmpty() bool
func (NullString) IsValid ¶
func (ns NullString) IsValid() bool
func (NullString) MarshalJSON ¶
func (ns NullString) MarshalJSON() ([]byte, error)
func (NullString) Result ¶
func (ns NullString) Result() interface{}
func (*NullString) UnmarshalJSON ¶
func (ns *NullString) UnmarshalJSON(b []byte) error
type QueryBuilder ¶
type QueryBuilder struct {
// contains filtered or unexported fields
}
QueryBuilder 查询构造器
func (*QueryBuilder) Between ¶
func (query *QueryBuilder) Between(column string, value1 interface{}, value2 interface{}) *QueryBuilder
Between 构造Between
func (*QueryBuilder) Equal ¶
func (query *QueryBuilder) Equal(column string, value interface{}) *QueryBuilder
Equal 构造等于
func (*QueryBuilder) Exec ¶
func (query *QueryBuilder) Exec(sql string, args ...interface{}) (int64, error)
Exec 原始SQl语句执行
func (*QueryBuilder) ExecSQL ¶
func (query *QueryBuilder) ExecSQL(sql string, args ...interface{}) string
ExecSQL 原始SQl语句执行
func (*QueryBuilder) GroupBy ¶
func (query *QueryBuilder) GroupBy(groups ...string) *QueryBuilder
GroupBy .
func (*QueryBuilder) In ¶
func (query *QueryBuilder) In(column string, value ...interface{}) *QueryBuilder
In 构造 in语句
func (*QueryBuilder) InnerJoin ¶
func (query *QueryBuilder) InnerJoin(tablename string, on string) *QueryBuilder
func (*QueryBuilder) Insert ¶
func (query *QueryBuilder) Insert(data interface{}) (int64, error)
Insert 插入数据
func (*QueryBuilder) InsertSQL ¶
func (query *QueryBuilder) InsertSQL(data interface{}) string
InsertSQL 获取SQL语句
func (*QueryBuilder) InsertUpdate ¶
func (query *QueryBuilder) InsertUpdate(insert interface{}, update interface{}) (int64, error)
InsertUpdate ...
func (*QueryBuilder) InsertUpdateSQL ¶
func (query *QueryBuilder) InsertUpdateSQL(insert interface{}, update interface{}) string
InsertUpdateSQL ...
func (*QueryBuilder) IsNULL ¶
func (query *QueryBuilder) IsNULL(column string) *QueryBuilder
IsNULL .
func (*QueryBuilder) IsNotNULL ¶
func (query *QueryBuilder) IsNotNULL(column string) *QueryBuilder
IsNotNULL .
func (*QueryBuilder) Join ¶
func (query *QueryBuilder) Join(tablename string, on string) *QueryBuilder
Join .
func (*QueryBuilder) LeftJoin ¶
func (query *QueryBuilder) LeftJoin(tablename string, on string) *QueryBuilder
LeftJoin .
func (*QueryBuilder) Like ¶
func (query *QueryBuilder) Like(column string, value interface{}) *QueryBuilder
Like .
func (*QueryBuilder) MultiInsert ¶
func (query *QueryBuilder) MultiInsert(datas ...interface{}) (int64, error)
MultiInsert 批量插入
func (*QueryBuilder) MultiInsertSQL ¶
func (query *QueryBuilder) MultiInsertSQL(datas ...interface{}) string
MultiInsertSQL 批量插入
func (*QueryBuilder) NotBetween ¶
func (query *QueryBuilder) NotBetween(column string, value1 interface{}, value2 interface{}) *QueryBuilder
NotBetween 构造不Not Between
func (*QueryBuilder) NotEqual ¶
func (query *QueryBuilder) NotEqual(column string, value interface{}) *QueryBuilder
NotEqual 构造不等于
func (*QueryBuilder) NotIn ¶
func (query *QueryBuilder) NotIn(column string, value ...interface{}) *QueryBuilder
NotIn .
func (*QueryBuilder) NotOrBetween ¶
func (query *QueryBuilder) NotOrBetween(column string, value1 interface{}, value2 interface{}) *QueryBuilder
NotOrBetween 构造 Not Between OR Not Between
func (*QueryBuilder) Offset ¶
func (query *QueryBuilder) Offset(offset int64) *QueryBuilder
Offset .
func (*QueryBuilder) OrBetween ¶
func (query *QueryBuilder) OrBetween(column string, value1 interface{}, value2 interface{}) *QueryBuilder
OrBetween 构造 或者 Between
func (*QueryBuilder) OrEqual ¶
func (query *QueryBuilder) OrEqual(column string, value interface{}) *QueryBuilder
OrEqual 构造或者等于
func (*QueryBuilder) OrIn ¶
func (query *QueryBuilder) OrIn(column string, value ...interface{}) *QueryBuilder
OrIn orin语句
func (*QueryBuilder) OrIsNULL ¶
func (query *QueryBuilder) OrIsNULL(column string) *QueryBuilder
OrIsNULL .
func (*QueryBuilder) OrIsNotNULL ¶
func (query *QueryBuilder) OrIsNotNULL(column string) *QueryBuilder
OrIsNotNULL .
func (*QueryBuilder) OrLike ¶
func (query *QueryBuilder) OrLike(column string, value interface{}) *QueryBuilder
OrLike .
func (*QueryBuilder) OrNotEqual ¶
func (query *QueryBuilder) OrNotEqual(column string, value interface{}) *QueryBuilder
OrNotEqual 构造或者不等于
func (*QueryBuilder) OrNotIn ¶
func (query *QueryBuilder) OrNotIn(column string, value ...interface{}) *QueryBuilder
OrNotIn .
func (*QueryBuilder) OrWhere ¶
func (query *QueryBuilder) OrWhere(column string, value ...interface{}) *QueryBuilder
OrWhere 构造OR条件
func (*QueryBuilder) OrderBy ¶
func (query *QueryBuilder) OrderBy(column string, direction string) *QueryBuilder
OrderBy .
func (*QueryBuilder) QueryRow ¶
func (query *QueryBuilder) QueryRow(sql string, args ...interface{}) *Row
QueryRow ...
func (*QueryBuilder) QueryRowSQL ¶
func (query *QueryBuilder) QueryRowSQL(sql string, args ...interface{}) string
QueryRowSQL ...
func (*QueryBuilder) QueryRows ¶
func (query *QueryBuilder) QueryRows(sql string, args ...interface{}) *Rows
QueryRows ...
func (*QueryBuilder) QueryRowsSQL ¶
func (query *QueryBuilder) QueryRowsSQL(sql string, args ...interface{}) string
QueryRowsSQL ...
func (*QueryBuilder) Replace ¶
func (query *QueryBuilder) Replace(datas ...interface{}) (int64, error)
Replace 替换
func (*QueryBuilder) ReplaceSQL ¶
func (query *QueryBuilder) ReplaceSQL(datas ...interface{}) string
ReplaceSQL 替换
func (*QueryBuilder) RightJoin ¶
func (query *QueryBuilder) RightJoin(tablename string, on string) *QueryBuilder
RightJoin .
func (*QueryBuilder) Select ¶
func (query *QueryBuilder) Select(columns ...string) *QueryBuilder
Select 查询字段
func (*QueryBuilder) Table ¶
func (query *QueryBuilder) Table(tablename ...string) *QueryBuilder
Table 设置操作的表名称
func (*QueryBuilder) Union ¶
func (query *QueryBuilder) Union(unions ...QueryBuilder) *QueryBuilder
Union .
func (*QueryBuilder) UnionAll ¶
func (query *QueryBuilder) UnionAll(unions ...QueryBuilder) *QueryBuilder
UnionAll .
func (*QueryBuilder) UnionLimit ¶
func (query *QueryBuilder) UnionLimit(limit int64) *QueryBuilder
UnionLimit .
func (*QueryBuilder) UnionOffset ¶
func (query *QueryBuilder) UnionOffset(offset int64) *QueryBuilder
UnionOffset .
func (*QueryBuilder) UnionOrderBy ¶
func (query *QueryBuilder) UnionOrderBy(column string, direction string) *QueryBuilder
UnionOrderBy .
func (*QueryBuilder) Update ¶
func (query *QueryBuilder) Update(data interface{}) (int64, error)
Update 更新
func (*QueryBuilder) UpdateSQL ¶
func (query *QueryBuilder) UpdateSQL(data interface{}) string
UpdateSQL 更新
func (*QueryBuilder) Where ¶
func (query *QueryBuilder) Where(column string, value ...interface{}) *QueryBuilder
Where 构造条件语句
type QueryDb ¶
type QueryDb struct { DB *sql.DB DriverName string Trace bool // contains filtered or unexported fields }
QueryDb mysql 配置
func (*QueryDb) Exec ¶
func (querydb *QueryDb) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
Exec 复用执行语句
func (*QueryDb) NewQuery ¶
func (querydb *QueryDb) NewQuery(ctx context.Context) *QueryBuilder
NewQuery 生成一个新的查询构造器
type QueryTx ¶
type QueryTx struct { TX *sql.Tx DriverName string Trace bool // contains filtered or unexported fields }
QueryTx 事务
func (*QueryTx) Exec ¶
func (querytx *QueryTx) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
Exec 复用执行语句
func (*QueryTx) NewQuery ¶
func (querytx *QueryTx) NewQuery(ctx context.Context) *QueryBuilder
NewQuery 生成一个新的查询构造器
type ResourceManager ¶
type ResourceManager struct {
// contains filtered or unexported fields
}
A ResourceManager is a manager that used to manage resources.
func NewResourceManager ¶
func NewResourceManager() *ResourceManager
NewResourceManager returns a ResourceManager.
func (*ResourceManager) Close ¶
func (manager *ResourceManager) Close() error
Close closes the manager. Don't use the ResourceManager after Close() called.
func (*ResourceManager) GetResource ¶
func (manager *ResourceManager) GetResource(key string, create func() (io.Closer, error)) (io.Closer, error)
GetResource returns the resource associated with given key.
type Row ¶
type Row struct {
// contains filtered or unexported fields
}
Row 获取记录
func (*Row) ToInterface ¶
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows get data
func (*Rows) ToInterface ¶
ToInterface []map[interface{}]interface{}
type SharedCalls ¶
type SharedCalls = SingleFlight
SharedCalls is an alias of SingleFlight. Deprecated: use SingleFlight.
type SingleFlight ¶
type SingleFlight interface { Do(key string, fn func() (interface{}, error)) (interface{}, error) DoEx(key string, fn func() (interface{}, error)) (interface{}, bool, error) }
SingleFlight lets the concurrent calls with the same key to share the call result. For example, A called F, before it's done, B called F. Then B would not execute F, and shared the result returned by F which called by A. The calls with the same key are dependent, concurrent calls share the returned values. A ------->calls F with key<------------------->returns val B --------------------->calls F with key------>returns val
func NewSharedCalls ¶
func NewSharedCalls() SingleFlight
NewSharedCalls returns a SingleFlight. Deprecated: use NewSingleFlight.