Documentation ¶
Overview ¶
Package tinypostgres provides utilities for handling Postgres.
Index ¶
Constants ¶
View Source
const ( // ErrUnknown is returned for all errors with unknown cause. ErrUnknown = iota // ErrUniqueViolation is returned for unique constraint violations. ErrUniqueViolation // ErrNotNullViolation is returned for non-null constraint violations. ErrNotNullViolation // ErrRecordNotFound is returned when query is expected to return a single record, but none are returned. ErrRecordNotFound // ErrInvalidText is returned when you try assigned invalid value to types such as uuid. ErrInvalidText )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { // Verbose specifies whether to log all executed queries. Verbose bool // PoolMaxOpen is the maximum number of open connections to the database (default: 10). PoolMaxOpen int // PoolMaxIdle is the maximum number of connections in the idle connection pool (default: 5). PoolMaxIdle int // PoolMaxLifetime is the maximum amount of time a connection may be reused (default: 1h). PoolMaxLifetime time.Duration // PoolMaxIdleTime is the maximum amount of time a connection may be idle (default: 30m). PoolMaxIdleTime time.Duration // GormOpt allows to specify custom function that will operate directly on *gorm.Config. GormOpt func(*gorm.Config) }
Config holds a configuration for Dial.
type Error ¶
type Error struct { // Err is the wrapped error. Err error // Code is the error code. Code int // Constraint is the name of violated constraint. Constraint string // TableName is the name of the table. TableName string // ColumnName is the name of the column. ColumnName string // Message is the message returned by the DB. Message string }
Error represents a wrapped query error.
func TranslateError ¶
TranslateError tries to cast given error instance to PgError and extract enough information to build Error instance.
Click to show internal directories.
Click to hide internal directories.