db

package
v0.0.0-...-5f682be Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	DB() DB
	Close() error
}

Client клиент для работы с БД

type DB

type DB interface {
	SQLExecer
	Transactor
	Pinger
	Close()
}

DB интерфейс для работы с БД

type Handler

type Handler func(ctx context.Context) error

Handler - функция, которая выполняется в транзакции

type NamedExecer

type NamedExecer interface {
	ScanOneContext(ctx context.Context, dest interface{}, q Query, args ...interface{}) error
	ScanAllContext(ctx context.Context, dest interface{}, q Query, args ...interface{}) error
}

NamedExecer интерфейс для работы с именованными запросами с помощью тегов в структурах

type Pinger

type Pinger interface {
	Ping(ctx context.Context) error
}

Pinger интерфейс для проверки соединения с БД

type Query

type Query struct {
	Name     string
	QueryRaw string
}

Query обертка над запросом, хранящая имя запроса и сам запрос Имя запроса используется для логирования и потенциально может использоваться еще где-то, например, для трейсинга

type QueryExecer

type QueryExecer interface {
	ExecContext(ctx context.Context, q Query, args ...interface{}) (pgconn.CommandTag, error)
	QueryContext(ctx context.Context, q Query, args ...interface{}) (pgx.Rows, error)
	QueryRowContext(ctx context.Context, q Query, args ...interface{}) pgx.Row
}

QueryExecer интерфейс для работы с обычными запросами

type SQLExecer

type SQLExecer interface {
	NamedExecer
	QueryExecer
}

SQLExecer комбинирует NamedExecer и QueryExecer

type Transactor

type Transactor interface {
	BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)
}

Transactor интерфейс для работы с транзакциями

type TxManager

type TxManager interface {
	ReadCommitted(ctx context.Context, f Handler) error
}

TxManager менеджер транзакций, который выполняет указанный пользователем обработчик в транзакции

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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