transaction

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithTransaction

func WithTransaction(ctx context.Context, opt *sql.TxOptions, db TxxI, fn ...TxFn) error

WithTransaction execute [1...n] TxFn used one transaction The provided context is used until the transaction is committed or rolled back. If the context is canceled, the sql package will roll back the transaction. Tx.Commit will return an error if the context is canceled. TxOptions holds the transaction options to be used in DB.BeginTx.

Types

type TxFn

type TxFn = func(*sqlx.Tx) error

TxFn is a function that will be called with an initialized `Transaction` object that can be used for executing statements and queries against a database.

type TxxI

type TxxI interface {
	// BeginTxx begins a transaction and returns an *sqlx.Tx instead of an *sql.Tx.
	BeginTxx(ctx context.Context, opts *sql.TxOptions) (*sqlx.Tx, error)
}

TxxI interface which contain sqlx.BeginTxx func.

Jump to

Keyboard shortcuts

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