Documentation
¶
Index ¶
- func ConnectToUrl(url string, opts ...func(*pgxpool.Config)) (*pgxpool.Pool, error)
- func GetScalar[T any](ctx context.Context, db IQueryRow, stmt string, args ...any) (T, error)
- func GetScalars[T any](ctx context.Context, db IQuery, stmt string, args ...any) ([]T, error)
- func LogIgnore(ctx context.Context) context.Context
- func LogUnignore(ctx context.Context) context.Context
- func WithTransaction(ctx context.Context, db IBegin, cb func(pgx.Tx) error) error
- type IBegin
- type IExec
- type IQuery
- type IQueryRow
- type LoggingTracer
- type LoggingTracerCtxKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectToUrl ¶
ConnectToUrl opens a connection pool using the given URL.
func GetScalars ¶
GetScalars returns a slice like []int{123, 123} from the query "SELECT 123 FROM generate_series(0,1)".
Types ¶
type LoggingTracer ¶
type LoggingTracer struct{}
LoggingTracer logs all SQL statements to the logger in the context, using logctx.Logger. Or add Ignore into the context to skip logging, like when calling River. Until River supports some alternative context factory or similar, there's not much we can do. See https://github.com/riverqueue/river/issues/511 for more info.
func NewLoggingTracer ¶
func NewLoggingTracer() *LoggingTracer
func (*LoggingTracer) TraceQueryEnd ¶
func (lt *LoggingTracer) TraceQueryEnd(ctx context.Context, _ *pgx.Conn, data pgx.TraceQueryEndData)
func (*LoggingTracer) TraceQueryStart ¶
func (lt *LoggingTracer) TraceQueryStart(ctx context.Context, _ *pgx.Conn, data pgx.TraceQueryStartData) context.Context
type LoggingTracerCtxKey ¶
type LoggingTracerCtxKey string
const Ignore LoggingTracerCtxKey = "pgxt.loggingtracer.ignore"
Click to show internal directories.
Click to hide internal directories.