database

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(dsn string) (*sqlx.DB, error)

New returns database connection

func TxFromContext

func TxFromContext(ctx context.Context) (*sqlx.Tx, bool)

TxFromContext retrieves the transaction from context if present

func WithTx

func WithTx(ctx context.Context, tx *sqlx.Tx) context.Context

WithTx adds a transaction to the context

Types

type Ex

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

Ex wraps db/tx with context

func (*Ex) Exec

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

Exec executes a query with context

func (*Ex) Get

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

Get retrieves a single row with context

type Executor

type Executor interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	GetContext(ctx context.Context, dest any, query string, args ...any) error
}

Executor represents database/transaction interface

type Querier

type Querier interface {
	Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
	Get(ctx context.Context, dest any, query string, args ...any) error
}

Querier represents types that can execute SQL queries with context already embedded

func NewQuerier

func NewQuerier(db Executor) Querier

NewQuerier creates a new Querier

Directories

Path Synopsis
Package database_mocks is a generated GoMock package.
Package database_mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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