Documentation ¶
Index ¶
- Variables
- func CheckSqlxTranContextExist(ctx context.Context) bool
- func Exec(e sqlx.Execer, query string, args ...interface{}) (sql.Result, error)
- func ExecContext(ctx context.Context, e sqlx.ExecerContext, query string, args ...interface{}) (sql.Result, error)
- func ExecTransaction(ctx context.Context, f TransactionFunc, opts ...ExecTransactionOption) (err error)
- func InterfaceToString(src interface{}) string
- func MapScan(r sqlx.ColScanner, dest map[string]interface{}) (err error)
- func NewSqlxContext(ctx context.Context, xdb *DB) context.Context
- func NewSqlxTranContext(ctx context.Context, xtx *Tx) context.Context
- func StringIndex(str string, s rune) (indexs []int)
- func StringIndexReplace(str string, indexs []int, args []interface{}) string
- type CreateSqlxTranContextFunc
- type DB
- func (that *DB) Exec(query string, args ...interface{}) (result sql.Result, err error)
- func (that *DB) ExecContext(ctx context.Context, query string, args ...interface{}) (result sql.Result, err error)
- func (that *DB) GetSqlxDB() *sqlx.DB
- func (that *DB) Prepare(query string) (stmt *sql.Stmt, err error)
- func (that *DB) PrepareContext(ctx context.Context, query string) (stmt *sql.Stmt, err error)
- func (that *DB) Query(query string, args ...interface{}) (rows *sql.Rows, err error)
- func (that *DB) QueryContext(ctx context.Context, query string, args ...interface{}) (rows *sql.Rows, err error)
- func (that *DB) QueryRowx(query string, args ...interface{}) *sqlx.Row
- func (that *DB) QueryRowxContext(ctx context.Context, query string, args ...interface{}) *sqlx.Row
- func (that *DB) Queryx(query string, args ...interface{}) (rows *sqlx.Rows, err error)
- func (that *DB) QueryxContext(ctx context.Context, query string, args ...interface{}) (rows *sqlx.Rows, err error)
- type DBConnect
- type ExecTransactionOption
- type ExecTransactionOptions
- type Logger
- type SqlxKey
- type SqlxTranKey
- type StdLogger
- type TransactionFunc
- type Tx
- func (that *Tx) Exec(query string, args ...interface{}) (result sql.Result, err error)
- func (that *Tx) ExecContext(ctx context.Context, query string, args ...interface{}) (result sql.Result, err error)
- func (that *Tx) GetSqlxTx() *sqlx.Tx
- func (that *Tx) Prepare(query string) (stmt *sql.Stmt, err error)
- func (that *Tx) PrepareContext(ctx context.Context, query string) (stmt *sql.Stmt, err error)
- func (that *Tx) Query(query string, args ...interface{}) (rows *sql.Rows, err error)
- func (that *Tx) QueryContext(ctx context.Context, query string, args ...interface{}) (rows *sql.Rows, err error)
- func (that *Tx) QueryRowx(query string, args ...interface{}) *sqlx.Row
- func (that *Tx) QueryRowxContext(ctx context.Context, query string, args ...interface{}) *sqlx.Row
- func (that *Tx) Queryx(query string, args ...interface{}) (rows *sqlx.Rows, err error)
- func (that *Tx) QueryxContext(ctx context.Context, query string, args ...interface{}) (rows *sqlx.Rows, err error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrContextNotFoundSqlx 上下文不存在Sqlx错误 ErrContextNotFoundSqlx = errors.New("上下文中没有获取到Sqlx") )
View Source
var ErrExecTransactionOptionDBIsNil = errors.New("db in options is nil")
Functions ¶
func CheckSqlxTranContextExist ¶
CheckSqlxTranContextExist 检查sqlx是否存在
func ExecContext ¶
func ExecContext(ctx context.Context, e sqlx.ExecerContext, query string, args ...interface{}) (sql.Result, error)
ExecContext error handling of sqlx.MustExecContext.
func ExecTransaction ¶
func ExecTransaction(ctx context.Context, f TransactionFunc, opts ...ExecTransactionOption) (err error)
func InterfaceToString ¶
func InterfaceToString(src interface{}) string
func MapScan ¶
func MapScan(r sqlx.ColScanner, dest map[string]interface{}) (err error)
MapScan 解决sqlx字节数组问题
func NewSqlxContext ¶
NewSqlxContext 创建Sqlx上下文
func NewSqlxTranContext ¶
NewSqlxTranContext 创建sqlx事务上下文
func StringIndex ¶
func StringIndexReplace ¶
Types ¶
type DB ¶
type DB struct { SqlxDB sqlxer Log Logger }
func (*DB) ExecContext ¶
func (*DB) PrepareContext ¶
func (*DB) QueryContext ¶
func (*DB) QueryRowxContext ¶
type DBConnect ¶
type DBConnect struct {
// contains filtered or unexported fields
}
func FromSqlxContext ¶
FromSqlxContext 从上下文中获取Sqlx
func (*DBConnect) IsTransaction ¶
func (*DBConnect) Transaction ¶
type ExecTransactionOption ¶
type ExecTransactionOption func(o *ExecTransactionOptions)
func WithExecTransactionCreateSqlxTranContextFunc ¶
func WithExecTransactionCreateSqlxTranContextFunc(f CreateSqlxTranContextFunc) ExecTransactionOption
func WithExecTransactionDB ¶
func WithExecTransactionDB(db *sqlx.DB) ExecTransactionOption
func WithExecTransactionLogger ¶
func WithExecTransactionLogger(log Logger) ExecTransactionOption
type ExecTransactionOptions ¶
type ExecTransactionOptions struct { DB *sqlx.DB Log Logger CreateSqlxTranContextFunc CreateSqlxTranContextFunc }
type Logger ¶
type Logger interface { // Printf 打印 Printf(ctx context.Context, query string, args ...interface{}) // Println 打印 Println(ctx context.Context, args ...interface{}) // Errorf 错误 Errorf(ctx context.Context, format string, args ...interface{}) // Errorln 错误 Errorln(ctx context.Context, args ...interface{}) }
Logger logger
type SqlxTranKey ¶
type SqlxTranKey struct{}
type StdLogger ¶
type StdLogger struct { }
StdLogger ...
type TransactionFunc ¶
type Tx ¶
type Tx struct { SqlxTx sqlxer Log Logger }
func (*Tx) ExecContext ¶
func (*Tx) PrepareContext ¶
func (*Tx) QueryContext ¶
func (*Tx) QueryRowxContext ¶
Click to show internal directories.
Click to hide internal directories.