context

package
v0.0.0-...-a757527 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) *sqlx.Tx

FromContext returns a transaction found in the context

func StartTx

func StartTx(ctx context.Context, db *sqlx.DB) (*sqlx.Tx, context.Context, error)

StartTx starts a transaction and injects it into the context

func WithTransaction

func WithTransaction(ctx context.Context, tx *sqlx.Tx) context.Context

WithTransaction returns a context with the transaction injected

Types

type QueryContext

type QueryContext interface {
	sqlx.QueryerContext
	Exec(query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

QueryContext returns something that can query or exec

func GetQueryer

func GetQueryer(ctx context.Context, db *sqlx.DB) QueryContext

GetQueryer returns a transaction or the database passed

Jump to

Keyboard shortcuts

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