tm

package
v0.0.0-...-a6e79c1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(db SQL, f TxnFunc) error

Run begins transaction around TxnFunc. It returns error and rollbacks if TxnFunc is failed. It commits if TxnFunc is successed.

func RunWithContext

func RunWithContext(ctx context.Context, opts *sql.TxOptions, db SQL, f TxnFunc) error

RunWithContext begins transaction with context.Conntext around TxnFunc. It returns error and rollbacks if TxnFunc is failed. It commits if TxnFunc is successed.

func Runx

func Runx(db SQLx, f TxnxFunc) error

Runx begins transaction around TxnxFunc. It returns error and rollbacks if TxnxFunc is failed. It commits if TxnxFunc is successed.

func RunxWithContext

func RunxWithContext(ctx context.Context, opts *sql.TxOptions, db SQLx, f TxnxFunc) error

RunxWithContext begins transaction with context.Conntext around TxnxFunc. It returns error and rollbacks if TxnxFunc is failed. It commits if TxnxFunc 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.

type SQLx

type SQLx interface {
	Beginx() (*sqlx.Tx, error)
	BeginTxx(context.Context, *sql.TxOptions) (*sqlx.Tx, error)
}

SQLx interface implements for *sqlx.DB or wrapped it.

type TxnFunc

type TxnFunc func(Executor) error

TxnFunc implemtnts for func(Executor) error

type TxnxFunc

type TxnxFunc func(Executorx) error

TxnxFunc implemtnts for func(Executorx) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL