sql

package
v0.0.0-...-d27c6ed Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: MIT Imports: 22 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, JobsQCPU *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. For documentation on OTel spans and attributes, see https://opentelemetry.io/docs/specs/semconv/database/database-spans/

func (*Helper) Connect

func (h *Helper) Connect(ctx context.Context) 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) InTx

func (h *Helper) InTx(ctx context.Context, cb func(ctx context.Context, 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 JobQueueOptions

type JobQueueOptions struct {
	Timeout time.Duration
}

type NewHelperOptions

type NewHelperOptions struct {
	JobQueue JobQueueOptions
	Log      *slog.Logger
	Postgres PostgresOptions
	SQLite   SQLiteOptions
}

type PostgresOptions

type PostgresOptions struct {
	ConnectionMaxIdleTime time.Duration
	ConnectionMaxLifetime time.Duration
	MaxIdleConnections    int
	MaxOpenConnections    int
	URL                   string
}

type SQLiteOptions

type SQLiteOptions struct {
	Path string
}

type Tx

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

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

Directories

Path Synopsis
internal