Documentation ¶
Index ¶
- func Run(db SQL, f TxnFunc) error
- func RunWithContext(ctx context.Context, opts *sql.TxOptions, db SQL, f TxnFunc) error
- func Runx(db SQLx, f TxnxFunc) error
- func RunxWithContext(ctx context.Context, opts *sql.TxOptions, db SQLx, f TxnxFunc) error
- type Executor
- type Executorx
- type SQL
- type SQLx
- type TxnFunc
- type TxnxFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run begins transaction around TxnFunc. It returns error and rollbacks if TxnFunc is failed. It commits if TxnFunc is successed.
func RunWithContext ¶
RunWithContext begins transaction with context.Conntext around TxnFunc. It returns error and rollbacks if TxnFunc is failed. It commits if TxnFunc is successed.
Types ¶
type Executor ¶
type Executor interface { Exec(string, ...interface{}) (sql.Result, error) ExecContext(context.Context, string, ...interface{}) (sql.Result, error) Prepare(string) (*sql.Stmt, error) PrepareContext(context.Context, string) (*sql.Stmt, error) Query(string, ...interface{}) (*sql.Rows, error) QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) QueryRow(string, ...interface{}) *sql.Row QueryRowContext(context.Context, string, ...interface{}) *sql.Row Stmt(*sql.Stmt) *sql.Stmt StmtContext(context.Context, *sql.Stmt) *sql.Stmt }
Executor interface implements for *sql.Tx or wrapped it. It has'nt Commit and Rollback methods.
type Executorx ¶
type Executorx interface { Executor Get(interface{}, string, ...interface{}) error GetContext(context.Context, interface{}, string, ...interface{}) error MustExec(string, ...interface{}) sql.Result MustExecContext(context.Context, string, ...interface{}) sql.Result NamedExec(string, interface{}) (sql.Result, error) NamedExecContext(context.Context, string, interface{}) (sql.Result, error) NamedQuery(string, interface{}) (*sqlx.Rows, error) NamedStmt(stmt *sqlx.NamedStmt) *sqlx.NamedStmt NamedStmtContext(context.Context, *sqlx.NamedStmt) *sqlx.NamedStmt PrepareNamedContext(context.Context, string) (*sqlx.NamedStmt, error) Preparex(string) (*sqlx.Stmt, error) PreparexContext(context.Context, string) (*sqlx.Stmt, error) QueryRowx(string, ...interface{}) *sqlx.Row QueryRowxContext(context.Context, string, ...interface{}) *sqlx.Row Queryx(string, ...interface{}) (*sqlx.Rows, error) QueryxContext(context.Context, string, ...interface{}) (*sqlx.Rows, error) Rebind(string) string Select(interface{}, string, ...interface{}) error SelectContext(context.Context, interface{}, string, ...interface{}) error Stmtx(interface{}) *sqlx.Stmt StmtxContext(context.Context, interface{}) *sqlx.Stmt Unsafe() *sqlx.Tx }
Executorx interface implements for *sqlx.Tx or wrapped it. It has'nt Commit and Rollback methods.
type SQL ¶
type SQL interface { Begin() (*sql.Tx, error) BeginTx(context.Context, *sql.TxOptions) (*sql.Tx, error) }
SQL interface implements for *sql.DB or wrapped it.
Click to show internal directories.
Click to hide internal directories.