Documentation ¶
Overview ¶
Package sqlh contains some helpers for database/sql.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Rollback is used to rollback a transaction without returning an error. Rollback = errors.New("Just rollback") )
Functions ¶
Types ¶
type Queryer ¶
type Queryer interface { ExecContext(context.Context, string, ...interface{}) (sql.Result, error) PrepareContext(context.Context, string) (*sql.Stmt, error) QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) QueryRowContext(context.Context, string, ...interface{}) *sql.Row }
Queryer abstracts sql.DB/sql.Conn/sql.Tx .
type TxOptions ¶
type TxOptions struct { sql.TxOptions // BeforeTx will be called (if not nil) before transaction starts. // `conn` is the db session used to start transaction. // If the callback returns an error, WithTxOpts returns that error and the transaction // will not start. BeforeTx func(ctx context.Context, conn *sql.Conn) error // AfterTx will be called (if not nil) after transaction finished with the commit status. // `conn` is the db session used to start transaction. AfterTx func(ctx context.Context, conn *sql.Conn, committed bool) }
TxOptions contains extra options for a db transaction.
Click to show internal directories.
Click to hide internal directories.