database

package
v0.0.28 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UniqueViolation     = "23505" // Нарушение уникального ограничения (duplicate key)
	NotNullViolation    = "23502" // Нарушение NOT NULL ограничения
	ForeignKeyViolation = "23503" // Нарушение FOREIGN KEY
	CheckViolation      = "23514" // CHECK constraint violation
	StringTooLong       = "22001" // Превышена длина столбца
	TableNotFound       = "42P01" // Таблица не найдена
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MinConns     int
	MaxConns     int
	MaxIdleConns time.Duration
	ConnLifetime time.Duration
}

type Database added in v0.0.8

type Database struct {
	Pool *pgxpool.Pool
}

func New added in v0.0.8

func New(ctx context.Context, cfg *Config) (*Database, error)

func (*Database) Close added in v0.0.8

func (d *Database) Close()

func (*Database) Ping added in v0.0.8

func (d *Database) Ping(ctx context.Context) error

func (*Database) RunInTransaction added in v0.0.8

func (d *Database) RunInTransaction(ctx context.Context, fn func(tx pgx.Tx) error) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL