Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrTxNotFound = errors.New("can not find transaction inside context")
Functions ¶
func MockManager ¶
func MockManager()
func SetupManager ¶
Types ¶
type Extension ¶
type Extension func(conn sqlx.ExtContext) sqlx.ExtContext
type ManagerTx ¶
type ManagerTx interface { // Do provide possibility to run transaction among all db functions inside txFunc. // Transaction level configurable by sql.Options. By default, will be applied // default level of used database, for example, 'read committed' in PostgreSQL. // // Example: // func main() { // tx.Manager().Do(ctx, func(ctx context.Context) error { // res, err := repo.GetItem(ctx, 1) // ... // err = nextRepo.SetItem(ctx, res) // }) // } Do(ctx context.Context, txFunc Func, opts ...sql.TxOptions) error // Conn extracts transaction from provided context.Context. If transaction is not // contains inside context.Context, then function return default database connection. // // Example: // func (r *repo) GetItem(ctx context.Context, id int64) (Item, error) { // conn := tx.Manager().Conn(ctx) // // res, err := conn.QueryContext(ctx, query) // ... // } Conn(ctx context.Context) sqlx.ExtContext }
ManagerTx is helper that provide possibility to execute group of database queries in single transaction.
Click to show internal directories.
Click to hide internal directories.