Documentation ¶
Index ¶
- Constants
- Variables
- func GetPGErrorColumn(err error) string
- func GetPGErrorConstraint(err error) string
- func HandleAdapterError(err error) (bool, error)
- func HandleResult(res sql.Result) error
- func IsErrNoRows(err error) bool
- func NewDatabaseLogger(before, after logFunction) bun.QueryHook
- type Configs
- type Database
- type Hook
- type InstanceType
- type Master
- type PostgresConfig
- type ReadReplica
- type SQLiteConfig
Constants ¶
View Source
const ( // IntegrityConstraintViolationErrorCode when a value is missing or not associated with a valid foreign table. IntegrityConstraintViolationErrorCode = "23000" // NotNullViolationErrorCode when received an empty or null field. NotNullViolationErrorCode = "23502" // ForeignKeyViolationErrorCode FK constraint was created with a not valid value. ForeignKeyViolationErrorCode = "23503" // UniqueViolationErrorCode duplicate key value violates unique constraint. UniqueViolationErrorCode = "23505" // CheckViolationErrorCode when a value violates a specific requirement in a column. CheckViolationErrorCode = "23514" // InvalidTextRepresentation when a field is uuid but receive a different pattern. InvalidTextRepresentation = "22P02" )
Variables ¶
View Source
var ( MasterInstanceType Master ReadReplicaInstanceType ReadReplica Nil = database[any, any]{} )
View Source
var ( ErrStatementTimeout = errors.New("statement timeout") ErrIntegrityConstraintViolation = errors.New("integrity constraint violation") ErrNotNullViolation = errors.New("not null violation") ErrForeignKeyViolation = errors.New("foreign key violation") ErrCheckViolation = errors.New("check violation") ErrUniqueViolation = errors.New("unique violation") ErrInternal = errors.New("internal server error") ErrNotFound = errors.New("it was not found") ErrInvalidTextRepresentation = errors.New("invalid text representation") ErrNoRowsAffected = errors.New("no rows affected") )
Functions ¶
func GetPGErrorColumn ¶
func GetPGErrorConstraint ¶
func HandleAdapterError ¶
func HandleResult ¶
func IsErrNoRows ¶
func NewDatabaseLogger ¶
NewDatabaseLogger returns a new implementation QueryHook to log SQL queries on console.
Types ¶
type Configs ¶
type Configs interface { any | PostgresConfig | SQLiteConfig }
type Database ¶
type InstanceType ¶
type InstanceType interface { any | Master | ReadReplica }
type PostgresConfig ¶
type ReadReplica ¶
type ReadReplica struct{}
type SQLiteConfig ¶
Click to show internal directories.
Click to hide internal directories.