Documentation
¶
Index ¶
- type Client
- func (db *Client) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (db *Client) ExecNamed(ctx context.Context, query string, arg any) (sql.Result, error)
- func (db *Client) RunInTransaction(ctx context.Context, txFunc TxFunc, opts ...TxOption) (err error)
- func (db *Client) Select(ctx context.Context, ptr any, query string, args ...any) error
- func (db *Client) SelectRow(ctx context.Context, ptr any, query string, args ...any) error
- type Config
- type DB
- type MigrationRunner
- type Option
- type Transactional
- type Tx
- func (t *Tx) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (t *Tx) ExecNamed(ctx context.Context, query string, arg any) (sql.Result, error)
- func (t *Tx) Select(ctx context.Context, ptr any, query string, args ...any) error
- func (t *Tx) SelectRow(ctx context.Context, ptr any, query string, args ...any) error
- type TxFunc
- type TxOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
func (*Client) RunInTransaction ¶
type Config ¶
type Config struct {
Host string `validate:"required" schema:"Хост"`
Port int `validate:"required" schema:"Порт"`
Database string `validate:"required" schema:"База данных"`
Username string `schema:"Логин" yamlschema:"secret"`
Password string `schema:"Пароль" yamlschema:"secret"`
Schema string `schema:"Схема"`
MaxOpenConn int `schema:"Максимально количество соединений"`
Params map[string]string `schema:"Дополнительные параметры подключения"`
}
type DB ¶
type DB interface {
Select(ctx context.Context, ptr any, query string, args ...any) error
SelectRow(ctx context.Context, ptr any, query string, args ...any) error
Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
ExecNamed(ctx context.Context, query string, arg any) (sql.Result, error)
}
type MigrationRunner ¶
type Transactional ¶
type TxOption ¶
type TxOption func(options *txOptions)
func IsolationLevel ¶
func IsolationLevel(level sql.IsolationLevel) TxOption
Click to show internal directories.
Click to hide internal directories.