Documentation ¶
Index ¶
- Variables
- func WithContext(ctx context.Context, db *DB) context.Context
- func WrapError(err error) error
- type DB
- func (d *DB) Close() error
- func (d *DB) Exec(query string, args ...interface{}) (sql.Result, error)
- func (d *DB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (d *DB) Get(dest interface{}, query string, args ...interface{}) error
- func (d *DB) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (d *DB) QueryRowx(query string, args ...interface{}) *sqlx.Row
- func (d *DB) QueryRowxContext(ctx context.Context, query string, args ...interface{}) *sqlx.Row
- func (d *DB) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
- func (d *DB) QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
- func (d *DB) Select(dest interface{}, query string, args ...interface{}) error
- func (d *DB) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (d *DB) Transaction(fn func(tx *Tx) error) error
- func (d *DB) TransactionContext(ctx context.Context, fn func(tx *Tx) error) error
- type Handler
- type Tx
- func (t *Tx) Exec(query string, args ...interface{}) (sql.Result, error)
- func (t *Tx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (t *Tx) Get(dest interface{}, query string, args ...interface{}) error
- func (t *Tx) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (t *Tx) QueryRowx(query string, args ...interface{}) *sqlx.Row
- func (t *Tx) QueryRowxContext(ctx context.Context, query string, args ...interface{}) *sqlx.Row
- func (t *Tx) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
- func (t *Tx) QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
- func (t *Tx) Select(dest interface{}, query string, args ...interface{}) error
- func (t *Tx) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDuplicateKey is a constraint violation error. ErrDuplicateKey = errors.New("duplicate key value violates table constraint") // ErrRecordNotFound is returned when a record is not found. ErrRecordNotFound = sql.ErrNoRows )
var ContextKey = struct{ string }{"db"}
ContextKey is the key used to store the database in the context.
Functions ¶
func WithContext ¶
WithContext returns a new context with the database.
Types ¶
type DB ¶
DB is the interface for a Soft Serve database.
func FromContext ¶
FromContext returns the database from the context.
func (*DB) ExecContext ¶
func (d *DB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
ExecContext is a wrapper around sqlx.ExecContext that logs the query and arguments.
func (*DB) GetContext ¶
func (d *DB) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
GetContext is a wrapper around sqlx.GetContext that logs the query and arguments.
func (*DB) QueryRowx ¶
QueryRowx is a wrapper around sqlx.QueryRowx that logs the query and arguments.
func (*DB) QueryRowxContext ¶
QueryRowxContext is a wrapper around sqlx.QueryRowxContext that logs the query and arguments.
func (*DB) QueryxContext ¶
func (d *DB) QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
QueryxContext is a wrapper around sqlx.QueryxContext that logs the query and arguments.
func (*DB) SelectContext ¶
func (d *DB) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
SelectContext is a wrapper around sqlx.SelectContext that logs the query and arguments.
func (*DB) Transaction ¶
Transaction implements db.DB.
type Handler ¶
type Handler interface { Rebind(string) string Select(interface{}, string, ...interface{}) error Get(interface{}, string, ...interface{}) error Queryx(string, ...interface{}) (*sqlx.Rows, error) QueryRowx(string, ...interface{}) *sqlx.Row Exec(string, ...interface{}) (sql.Result, error) SelectContext(context.Context, interface{}, string, ...interface{}) error GetContext(context.Context, interface{}, string, ...interface{}) error QueryxContext(context.Context, string, ...interface{}) (*sqlx.Rows, error) QueryRowxContext(context.Context, string, ...interface{}) *sqlx.Row ExecContext(context.Context, string, ...interface{}) (sql.Result, error) }
Handler is a database handler.
type Tx ¶
Tx is a database transaction.
func (*Tx) ExecContext ¶
func (t *Tx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
ExecContext is a wrapper around sqlx.ExecContext that logs the query and arguments.
func (*Tx) GetContext ¶
func (t *Tx) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
GetContext is a wrapper around sqlx.GetContext that logs the query and arguments.
func (*Tx) QueryRowx ¶
QueryRowx is a wrapper around sqlx.QueryRowx that logs the query and arguments.
func (*Tx) QueryRowxContext ¶
QueryRowxContext is a wrapper around sqlx.QueryRowxContext that logs the query and arguments.
func (*Tx) QueryxContext ¶
func (t *Tx) QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
QueryxContext is a wrapper around sqlx.QueryxContext that logs the query and arguments.