postgres

package
v0.0.0-...-70d632b Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	DBName   string `yaml:"db"`
}

Config содержит конфигурацию подключения к базе данных.

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database обертка для работы с pgxpool.Pool.

func NewDB

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

NewDB создает новое подключение к базе данных.

func (*Database) Exec

func (db *Database) Exec(ctx context.Context, query string, args ...interface{}) (pgconn.CommandTag, error)

Exec выполняет запрос.

func (*Database) ExecQueryRow

func (db *Database) ExecQueryRow(ctx context.Context, query string, args ...interface{}) pgx.Row

ExecQueryRow выполняет запрос и возвращает строку.

func (*Database) Get

func (db *Database) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error

Get возвращает одну запись.

func (*Database) Select

func (db *Database) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error

Select выполняет запрос и возвращает результат.

type QueryEngine

type QueryEngine interface {
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
	Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
}

QueryEngine интерфейс для работы с запросами к бд.

Jump to

Keyboard shortcuts

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