sqlxmw

package
v0.0.0-...-fe6cffa Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2017 License: BSD-3-Clause Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetIndexedTx

func GetIndexedTx(ctx context.Context, index int) (*sqlx.Tx, error)

GetIndexedTx works like GetTx, except that it provides the option to specify which database to get a transaction from.

func GetRawDB

func GetRawDB(ctx context.Context, index int) (*sqlx.DB, error)

GetRawDB returns the raw database from the provided context, or nil if it does not exist. Prefer GetTx when you can.

func GetTx

func GetTx(ctx context.Context) (*sqlx.Tx, error)

GetTx returns a transaction for the provided context. Successive calls will return the same transaction, unless the transaction initialisation failed.

func WithDB

func WithDB(params WrapParams) mw.Middleware

WithDB returns a middleware which provides the context with a transaction and a database.

Types

type WrapParams

type WrapParams struct {
	// DB is the database to connect to. Has to be nonnil.
	DB *sqlx.DB
	// Options when starting a transactional
	DBOpts *sql.TxOptions
	// Index is the index of this database. This argument is optional and is not
	// necessary unless you need to connect to multiple different SQL databases.
	Index int
	// contains filtered or unexported fields
}

WrapParams is the set of input parameters

Jump to

Keyboard shortcuts

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