db

package
v1.35.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToSnakeCase

func ToSnakeCase(s string) string

Types

type Client

type Client struct {
	*sqlx.DB
	// contains filtered or unexported fields
}

func Open

func Open(ctx context.Context, dsn string, opts ...Option) (*Client, error)

func (*Client) Exec

func (db *Client) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)

func (*Client) ExecNamed

func (db *Client) ExecNamed(ctx context.Context, query string, arg any) (sql.Result, error)

func (*Client) RunInTransaction

func (db *Client) RunInTransaction(ctx context.Context, txFunc TxFunc, opts ...TxOption) (err error)

func (*Client) Select

func (db *Client) Select(ctx context.Context, ptr any, query string, args ...any) error

func (*Client) SelectRow

func (db *Client) SelectRow(ctx context.Context, ptr any, query string, args ...any) error

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 Option

type Option func(db *Client)

func WithQueryTracer

func WithQueryTracer(tracers ...pgx.QueryTracer) Option

type Transactional

type Transactional interface {
	RunInTransaction(ctx context.Context, txFunc TxFunc, opts ...TxOption) error
}

type Tx

type Tx struct {
	*sqlx.Tx
}

func (*Tx) Exec

func (t *Tx) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)

func (*Tx) ExecNamed

func (t *Tx) ExecNamed(ctx context.Context, query string, arg any) (sql.Result, error)

func (*Tx) Select

func (t *Tx) Select(ctx context.Context, ptr any, query string, args ...any) error

func (*Tx) SelectRow

func (t *Tx) SelectRow(ctx context.Context, ptr any, query string, args ...any) error

type TxFunc

type TxFunc func(ctx context.Context, tx *Tx) error

type TxOption

type TxOption func(options *txOptions)

func IsolationLevel

func IsolationLevel(level sql.IsolationLevel) TxOption

func ReadOnly

func ReadOnly() TxOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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