Documentation ¶
Index ¶
- Constants
- func DisableDebug()
- func EnableDebug()
- func Exec(tx AbstractDBBase, query string, args ...interface{}) (rowsAffected int64, success bool)
- func ExecInsert(tx AbstractDBBase, query string, args ...interface{}) (lastInsertId int64, success bool)
- func GetDefaultLocation() *time.Location
- func InterpolateParams(query string, args []driver.Value, loc *time.Location, ...) (string, error)
- func MustOpen(driverName string, dataSourceName string) *sqlx.DB
- func MustOpenWithOptions(driverName string, opts ConnectionOptions) *sqlx.DB
- func Open(driverName string, dataSourceName string) (*sqlx.DB, error)
- func OpenWithOptions(driverName string, opts ConnectionOptions) (*sqlx.DB, error)
- func QueryCount(tx AbstractDBBase, query string, args ...interface{}) (count int64, success bool)
- func QueryMany(tx AbstractDBBase, dest interface{}, query string, args ...interface{}) (success bool)
- func QueryOne(tx AbstractDBBase, dest interface{}, query string, args ...interface{}) (success bool)
- func SetDefaultLocation(loc *time.Location)
- type AbstractDB
- type AbstractDBBase
- type AbstractTx
- type ConnectionOptions
- type DB
- type QueryBuilder
- func (q *QueryBuilder) And(query string, args ...driver.Value) *QueryBuilder
- func (q *QueryBuilder) AndRow(row Row) *QueryBuilder
- func (q *QueryBuilder) As(name string) *QueryBuilder
- func (q *QueryBuilder) Build() string
- func (q *QueryBuilder) Clone() *QueryBuilder
- func (q *QueryBuilder) Count(field string) *QueryBuilder
- func (q *QueryBuilder) Delete() *QueryBuilder
- func (q *QueryBuilder) Fields(fields ...string) *QueryBuilder
- func (q *QueryBuilder) Format(query string, args ...driver.Value) string
- func (q *QueryBuilder) GroupBy(tpl string, args ...driver.Value) *QueryBuilder
- func (q *QueryBuilder) Having(tpl string, args ...driver.Value) *QueryBuilder
- func (q *QueryBuilder) Init(quoteIdentifier func(id string) string, ...) *QueryBuilder
- func (q *QueryBuilder) InnerJoin(tableName string, fields ...string) *QueryBuilder
- func (q *QueryBuilder) Insert(row Row) *QueryBuilder
- func (q *QueryBuilder) InsertMany(rows []Row) *QueryBuilder
- func (q *QueryBuilder) Join(tableName string, fields ...string) *QueryBuilder
- func (q *QueryBuilder) LeftJoin(tableName string, fields ...string) *QueryBuilder
- func (q *QueryBuilder) Limit(n int) *QueryBuilder
- func (q *QueryBuilder) Location(loc *time.Location) *QueryBuilder
- func (q *QueryBuilder) On(condition string, args ...driver.Value) *QueryBuilder
- func (q *QueryBuilder) OnConflictDoUpdate(key string) *QueryBuilder
- func (q *QueryBuilder) OnDuplicateKeyUpdate() *QueryBuilder
- func (q *QueryBuilder) OrderBy(tpl string, args ...driver.Value) *QueryBuilder
- func (q *QueryBuilder) QuoteIdentifier(id string) string
- func (q *QueryBuilder) Returning(fields ...string) *QueryBuilder
- func (q *QueryBuilder) ReturningAll() *QueryBuilder
- func (q *QueryBuilder) RightJoin(tableName string, fields ...string) *QueryBuilder
- func (q *QueryBuilder) Select(fields ...string) *QueryBuilder
- func (q *QueryBuilder) SelectDistinct(fields ...string) *QueryBuilder
- func (q *QueryBuilder) Set(update string, args ...driver.Value) *QueryBuilder
- func (q *QueryBuilder) SetRow(row Row) *QueryBuilder
- func (q *QueryBuilder) Skip(n int) *QueryBuilder
- func (q *QueryBuilder) Table(tableName string) *QueryBuilder
- func (q *QueryBuilder) Update() *QueryBuilder
- func (q *QueryBuilder) Where(query string, args ...driver.Value) *QueryBuilder
- func (q *QueryBuilder) WhereRow(row Row) *QueryBuilder
- type QueryCountRow
- type Row
- type Tx
Constants ¶
View Source
const DELETE = "DELETE"
View Source
const INNER_JOIN = "INNER JOIN"
View Source
const INSERT = "INSERT"
View Source
const INSERT_OR_UPDATE_CONFLICT = "INSERT_OR_UPDATE_CONFLICT"
View Source
const INSERT_OR_UPDATE_DUPLICATE = "INSERT_OR_UPDATE_DUPLICATE"
View Source
const JOIN = "JOIN"
View Source
const LEFT_JOIN = "LEFT JOIN"
View Source
const RIGHT_JOIN = "RIGHT JOIN"
View Source
const SELECT = "SELECT"
View Source
const SELECT_DISTINCT = "SELECT DISTINCT"
View Source
const UPDATE = "UPDATE"
Variables ¶
This section is empty.
Functions ¶
func DisableDebug ¶
func DisableDebug()
func EnableDebug ¶
func EnableDebug()
func Exec ¶ added in v1.2.3
func Exec(tx AbstractDBBase, query string, args ...interface{}) (rowsAffected int64, success bool)
执行查询,无返回结果
func ExecInsert ¶ added in v1.2.5
func ExecInsert(tx AbstractDBBase, query string, args ...interface{}) (lastInsertId int64, success bool)
执行插入记录查询,返回最后插入ID
func GetDefaultLocation ¶ added in v1.2.0
func InterpolateParams ¶ added in v1.2.0
func MustOpenWithOptions ¶
func MustOpenWithOptions(driverName string, opts ConnectionOptions) *sqlx.DB
创建数据库连接,如果失败则panic
func OpenWithOptions ¶
func OpenWithOptions(driverName string, opts ConnectionOptions) (*sqlx.DB, error)
创建数据库连接
func QueryCount ¶ added in v1.2.5
func QueryCount(tx AbstractDBBase, query string, args ...interface{}) (count int64, success bool)
查询记录数量,需要 SELECT count(*) AS count FROM ... 这样的格式
func QueryMany ¶ added in v1.2.5
func QueryMany(tx AbstractDBBase, dest interface{}, query string, args ...interface{}) (success bool)
执行查询,有多行返回结果
func QueryOne ¶ added in v1.2.5
func QueryOne(tx AbstractDBBase, dest interface{}, query string, args ...interface{}) (success bool)
执行查询,有一行返回结果
func SetDefaultLocation ¶ added in v1.2.0
Types ¶
type AbstractDB ¶
type AbstractDB interface { AbstractDBBase MustBegin() AbstractTx }
type AbstractDBBase ¶
type AbstractTx ¶
type AbstractTx interface { AbstractDBBase Rollback() error Commit() error }
type ConnectionOptions ¶ added in v1.2.0
type ConnectionOptions interface {
BuildDataSourceString() string
}
type QueryBuilder ¶ added in v1.2.0
type QueryBuilder struct {
// contains filtered or unexported fields
}
func NewEmptyQuery ¶ added in v1.2.0
func NewEmptyQuery() *QueryBuilder
func Table ¶ added in v1.2.0
func Table(tableName string) *QueryBuilder
func (*QueryBuilder) And ¶ added in v1.2.0
func (q *QueryBuilder) And(query string, args ...driver.Value) *QueryBuilder
func (*QueryBuilder) AndRow ¶ added in v1.2.0
func (q *QueryBuilder) AndRow(row Row) *QueryBuilder
func (*QueryBuilder) As ¶ added in v1.2.0
func (q *QueryBuilder) As(name string) *QueryBuilder
func (*QueryBuilder) Build ¶ added in v1.2.0
func (q *QueryBuilder) Build() string
func (*QueryBuilder) Clone ¶ added in v1.2.0
func (q *QueryBuilder) Clone() *QueryBuilder
func (*QueryBuilder) Count ¶ added in v1.2.0
func (q *QueryBuilder) Count(field string) *QueryBuilder
func (*QueryBuilder) Delete ¶ added in v1.2.0
func (q *QueryBuilder) Delete() *QueryBuilder
func (*QueryBuilder) Fields ¶ added in v1.2.0
func (q *QueryBuilder) Fields(fields ...string) *QueryBuilder
func (*QueryBuilder) Format ¶ added in v1.2.0
func (q *QueryBuilder) Format(query string, args ...driver.Value) string
func (*QueryBuilder) GroupBy ¶ added in v1.2.0
func (q *QueryBuilder) GroupBy(tpl string, args ...driver.Value) *QueryBuilder
func (*QueryBuilder) Having ¶ added in v1.2.0
func (q *QueryBuilder) Having(tpl string, args ...driver.Value) *QueryBuilder
func (*QueryBuilder) Init ¶ added in v1.2.0
func (q *QueryBuilder) Init(quoteIdentifier func(id string) string, quoteLiteral func([]byte, string) []byte) *QueryBuilder
func (*QueryBuilder) InnerJoin ¶ added in v1.2.0
func (q *QueryBuilder) InnerJoin(tableName string, fields ...string) *QueryBuilder
func (*QueryBuilder) Insert ¶ added in v1.2.0
func (q *QueryBuilder) Insert(row Row) *QueryBuilder
func (*QueryBuilder) InsertMany ¶ added in v1.2.0
func (q *QueryBuilder) InsertMany(rows []Row) *QueryBuilder
func (*QueryBuilder) Join ¶ added in v1.2.0
func (q *QueryBuilder) Join(tableName string, fields ...string) *QueryBuilder
func (*QueryBuilder) LeftJoin ¶ added in v1.2.0
func (q *QueryBuilder) LeftJoin(tableName string, fields ...string) *QueryBuilder
func (*QueryBuilder) Limit ¶ added in v1.2.0
func (q *QueryBuilder) Limit(n int) *QueryBuilder
func (*QueryBuilder) Location ¶ added in v1.2.0
func (q *QueryBuilder) Location(loc *time.Location) *QueryBuilder
func (*QueryBuilder) On ¶ added in v1.2.0
func (q *QueryBuilder) On(condition string, args ...driver.Value) *QueryBuilder
func (*QueryBuilder) OnConflictDoUpdate ¶ added in v1.2.7
func (q *QueryBuilder) OnConflictDoUpdate(key string) *QueryBuilder
func (*QueryBuilder) OnDuplicateKeyUpdate ¶ added in v1.2.0
func (q *QueryBuilder) OnDuplicateKeyUpdate() *QueryBuilder
func (*QueryBuilder) OrderBy ¶ added in v1.2.0
func (q *QueryBuilder) OrderBy(tpl string, args ...driver.Value) *QueryBuilder
func (*QueryBuilder) QuoteIdentifier ¶ added in v1.2.0
func (q *QueryBuilder) QuoteIdentifier(id string) string
func (*QueryBuilder) Returning ¶ added in v1.2.3
func (q *QueryBuilder) Returning(fields ...string) *QueryBuilder
func (*QueryBuilder) ReturningAll ¶ added in v1.2.3
func (q *QueryBuilder) ReturningAll() *QueryBuilder
func (*QueryBuilder) RightJoin ¶ added in v1.2.0
func (q *QueryBuilder) RightJoin(tableName string, fields ...string) *QueryBuilder
func (*QueryBuilder) Select ¶ added in v1.2.0
func (q *QueryBuilder) Select(fields ...string) *QueryBuilder
func (*QueryBuilder) SelectDistinct ¶ added in v1.2.0
func (q *QueryBuilder) SelectDistinct(fields ...string) *QueryBuilder
func (*QueryBuilder) Set ¶ added in v1.2.0
func (q *QueryBuilder) Set(update string, args ...driver.Value) *QueryBuilder
func (*QueryBuilder) SetRow ¶ added in v1.2.0
func (q *QueryBuilder) SetRow(row Row) *QueryBuilder
func (*QueryBuilder) Skip ¶ added in v1.2.0
func (q *QueryBuilder) Skip(n int) *QueryBuilder
func (*QueryBuilder) Table ¶ added in v1.2.0
func (q *QueryBuilder) Table(tableName string) *QueryBuilder
func (*QueryBuilder) Update ¶ added in v1.2.0
func (q *QueryBuilder) Update() *QueryBuilder
func (*QueryBuilder) Where ¶ added in v1.2.0
func (q *QueryBuilder) Where(query string, args ...driver.Value) *QueryBuilder
func (*QueryBuilder) WhereRow ¶ added in v1.2.0
func (q *QueryBuilder) WhereRow(row Row) *QueryBuilder
type QueryCountRow ¶
type QueryCountRow struct {
Count int64 `db:"count"`
}
Click to show internal directories.
Click to hide internal directories.