pgctx

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2019 License: MIT Imports: 4 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Committed

func Committed(ctx context.Context, f func(ctx context.Context))

Committed calls f after committed

func Exec

func Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

Exec calls db.ExecContext

func Middleware

func Middleware(db DB) func(h http.Handler) http.Handler

Middleware injects db into request's context

func NewContext

func NewContext(ctx context.Context, db DB) context.Context

NewContext creates new context

func Query

func Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

Query calls db.QueryContext

func QueryRow

func QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row

QueryRow calls db.QueryRowContext

func RunInTx

func RunInTx(ctx context.Context, f func(ctx context.Context) error) error

RunInTx starts sql tx if not started

Types

type DB

type DB interface {
	Queryer
	pgsql.BeginTxer
}

type Queryer

type Queryer interface {
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
}

Queryer interface

Jump to

Keyboard shortcuts

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