sql

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoRows = sql.ErrNoRows

Functions

This section is empty.

Types

type Helper

type Helper struct {
	DB    *sqlx.DB
	JobsQ *goqite.Queue
	// contains filtered or unexported fields
}

func NewHelper

func NewHelper(opts NewHelperOptions) *Helper

NewHelper with the given options. If no logger is provided, logs are discarded.

func (*Helper) Connect

func (h *Helper) Connect() error

func (*Helper) Exec

func (h *Helper) Exec(ctx context.Context, query string, args ...any) error

func (*Helper) Get

func (h *Helper) Get(ctx context.Context, dest any, query string, args ...any) error

func (*Helper) InTransaction

func (h *Helper) InTransaction(ctx context.Context, callback func(tx *Tx) error) (err error)

InTransaction runs callback in a transaction, and makes sure to handle rollbacks, commits etc.

func (*Helper) MigrateDown

func (h *Helper) MigrateDown(ctx context.Context) error

func (*Helper) MigrateUp

func (h *Helper) MigrateUp(ctx context.Context) error

func (*Helper) Ping

func (h *Helper) Ping(ctx context.Context) error

func (*Helper) Select

func (h *Helper) Select(ctx context.Context, dest any, query string, args ...any) error

type NewHelperOptions

type NewHelperOptions struct {
	Log  *slog.Logger
	Path string
}

type Tx

type Tx struct {
	Tx *sqlx.Tx
}

func (*Tx) Exec

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

func (*Tx) Get

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

func (*Tx) Select

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