Documentation ¶
Index ¶
- Variables
- func ClassifyError(err error) *errx.Kind
- func DeferredRollback(ctx context.Context, tx pgx.Tx)
- 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 Db
Constants ¶
This section is empty.
Variables ¶
View Source
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 ¶
Click to show internal directories.
Click to hide internal directories.