sqlxtransaction

package
v1.101.9 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package sqlxtransaction provides a simple way to execute a function inside an SQLX transaction. The function to be executed is passed as an argument to the Exec function.

For a similar functionality using the standard database/sql package instead of the github.com/jmoiron/sqlx one, see the github.com/Vonage/gosrvlib/pkg/sqltransaction package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec(ctx context.Context, db DB, run ExecFunc) error

Exec executes the specified function inside a SQL transaction.

func ExecWithOptions

func ExecWithOptions(ctx context.Context, db DB, run ExecFunc, opts *sql.TxOptions) error

ExecWithOptions executes the specified function inside a SQL transaction.

Types

type DB

type DB interface {
	BeginTxx(ctx context.Context, opts *sql.TxOptions) (*sqlx.Tx, error)
}

DB is the interface which represents the database driver.

type ExecFunc

type ExecFunc func(ctx context.Context, tx *sqlx.Tx) error

ExecFunc is the type of the function to be executed inside a SQL Transaction.

Jump to

Keyboard shortcuts

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