dbx

package
v0.0.0-...-f4dd3ec Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StatementBuilder = squirrel.StatementBuilderType(builder.EmptyBuilder).PlaceholderFormat(squirrel.Dollar)
View Source
var TxContextKey contextKey = struct{}{}

Functions

func AdjustRelation

func AdjustRelation[S interface {
	Keyer
	comparable
}](
	prev, next []S,
	addFn, removeFn ChangeRelationFunc[S],
) error

func InTransaction

func InTransaction(ctx context.Context, db *pgxpool.Pool, fn func(ctx2 context.Context, tx pgx.Tx) error) error

func IsForeignKeyViolation

func IsForeignKeyViolation(err error, name string) bool

func IsNoRows

func IsNoRows(err error) bool

func IsUniqueViolation

func IsUniqueViolation(err error, name string) bool

func NotValidEnumType

func NotValidEnumType(err error) bool

func QueryBatch

func QueryBatch(b *pgx.Batch, sb squirrel.Sqlizer) error

func ReassignPositions

func ReassignPositions[S ~[]E, E Positioner, Q Queryable](q Q, elements S, updateFn ChangePositionsFunc[Q, E]) error

func WithTransaction

func WithTransaction(ctx context.Context, tx pgx.Tx) context.Context

Types

type ChangePositionsFunc

type ChangePositionsFunc[Q Queryable, S any] func(Q, S) error

type ChangeRelationFunc

type ChangeRelationFunc[S any] func(S) error

type Keyer

type Keyer interface {
	Key() any
}

type Positioner

type Positioner interface {
	GetPosition() uint32
	SetPosition(pos uint32)
}

type Queryable

type Queryable interface {
	Exec(ctx context.Context, sql string, arguments ...any) (commandTag pgconn.CommandTag, err error)
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
}

func FromContext

func FromContext(ctx context.Context, def Queryable) Queryable

Jump to

Keyboard shortcuts

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