Documentation
¶
Index ¶
- Variables
- func IScanRows[T any](rows *sqlx.Rows, processFunc func(T) error) error
- func RequireExactSelectNamedCtx[T any](ctx context.Context, expected int, db sqlx.ExtContext, query string, args any) ([]T, error)
- func ScanRows[T any](rows *sqlx.Rows) ([]T, error)
- func SelectNamedCtx[T any](ctx context.Context, db sqlx.ExtContext, query string, args any) ([]T, error)
- func WithTransaction(db *sqlx.DB, workFunc func(*sqlx.Tx) error) error
- func WithTransactionReturning[T any](db *sqlx.DB, workFunc func(tx *sqlx.Tx) (T, error)) (T, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFoundError = errors.New("not found") ErrUnexpectedRowCountError = errors.New("unexpected row count") )
Functions ¶
func IScanRows ¶
IScanRows scans each row into the indicated struct, and calls the process function on it, stopping on the first error. It delegates the closing of the rows object to the caller
func RequireExactSelectNamedCtx ¶
func RequireExactSelectNamedCtx[T any](ctx context.Context, expected int, db sqlx.ExtContext, query string, args any) ([]T, error)
RequireExactSelectNamedCtx is like SelectNamedCtx, except it enforces that the number of rows returned matches an expected value
func ScanRows ¶
ScanRows scans each row object into the indicated struct, returning a list of all objects. It delegates the closing of the rows object to the caller
func SelectNamedCtx ¶
func SelectNamedCtx[T any](ctx context.Context, db sqlx.ExtContext, query string, args any) ([]T, error)
SelectNamedCtx executes a query with named paramters, and scans the results into the supplied struct
func WithTransaction ¶
WithTransaction is like WithTransactionReturning except does not return a value
func WithTransactionReturning ¶
WithTransactionReturning executes the provided function against the provided DB, rolling back if the given function returns error, or committing otherwise. The return value from the work function will be returned on success
Types ¶
This section is empty.