Documentation ¶
Index ¶
- Variables
- func ClassifyError(err error) *errx.Kind
- func DeferredRollback(ctx context.Context, tx pgx.Tx)
- func GetCtxPool(ctx context.Context) (*pgxpool.Pool, error)
- func GetCtxTx(ctx context.Context) (pgx.Tx, error)
- func ReadMany[R any](ctx context.Context, tx pgx.Tx, mainSql string, limit int, offset int, ...) ([]R, error)
- func ReadSingle[R any, F any](ctx context.Context, tx pgx.Tx, tableName string, fieldName string, ...) error
- func SflWithTransaction[R, S, T any](db Db, block func(ctx context.Context, tx pgx.Tx, reqCtx R, in S) (T, error)) func(ctx context.Context, reqCtx R, in S) (T, error)
- func SqlState(err error) string
- func WithTransaction[T any](db Db, ctx context.Context, ...) (T, error)
- type CtxPgx
- func (p CtxPgx) BeginTx(ctx context.Context) (context.Context, error)
- func (p CtxPgx) Commit(ctx context.Context) (context.Context, error)
- func (p CtxPgx) DeferredRollback(ctx context.Context)
- func (p CtxPgx) Rollback(ctx context.Context) (context.Context, error)
- func (p CtxPgx) SetPool(ctx context.Context) (context.Context, error)
- type CtxPgxPoolKeyT
- type CtxPgxTxKeyT
- type Db
- type RecCtx
Constants ¶
This section is empty.
Variables ¶
var ( DbErrRuntimeEnvironment = errx.NewKind("DbErrRuntimeEnvironment") DbErrInternalAppError = errx.NewKind("DbErrInternalAppError") DbErrConnectionException = errx.NewKind("DbErrConnectionException") DbErrConstraintViolation = errx.NewKind("DbErrConstraintViolation") DbErrUniqueViolation = errx.NewKind("DbErrUniqueViolation", DbErrConstraintViolation) DbErrInsufficientResources = errx.NewKind("DbErrInsufficientResources", DbErrRuntimeEnvironment) DbErrOperatorIntervention = errx.NewKind("DbErrOperatorIntervention", DbErrRuntimeEnvironment) DbErrExternalSystemError = errx.NewKind("DbErrExternalSystemError", DbErrRuntimeEnvironment) DbErrEngineError = errx.NewKind("DbErrEngineError", DbErrRuntimeEnvironment) DbErrRecordNotFound = errx.NewKind("DbErrRecordNotFound") DbErrUnexpectedMultipleRecords = errx.NewKind("DbErrUnexpectedMultipleRecords", DbErrInternalAppError) )
Functions ¶
func ClassifyError ¶
ClassifyError returns an database-related *errx.Kind that corresponds to err.
func DeferredRollback ¶
func ReadMany ¶
func ReadMany[R any]( ctx context.Context, tx pgx.Tx, mainSql string, limit int, offset int, args ...any, ) ([]R, error)
ReadMany reads an array of records from the database. `mainSql` is the main query string, which is appended with optional limit and offset clauses. If limit or offset is negative then the corresponding clause is not appended.
func ReadSingle ¶
func ReadSingle[R any, F any]( ctx context.Context, tx pgx.Tx, tableName string, fieldName string, fieldValue F, record *R, ) error
ReadSingle reads a single record from a table.
func SflWithTransaction ¶
Types ¶
type CtxPgx ¶
func (CtxPgx) DeferredRollback ¶
type RecCtx ¶
RecCtx is a type that holds platform-specific database record context information, e.g., an optimistic locking token and/or a record Id. DAFs may accept this type as a parameter or return this type, together with domain entity types. This type is parameterized to provide type safety, i.e., to prevent passing a RecCtx[U] on a call that involves entity type V.