function

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterTypes added in v0.0.3

func RegisterTypes(ctx context.Context, conn *pgx.Conn) error

RegisterTypes registers custom Postgres types (composites and enums) with the pgx connection's TypeMap so that they can be scanned and encoded correctly. Call this once per connection after connecting.

For pgxpool.Pool, use config.AfterConnect:

config.AfterConnect = func(ctx context.Context, conn *pgx.Conn) error {
	return RegisterTypes(ctx, conn)
}

Types

type DBQuerier

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

func NewQuerier

func NewQuerier(conn genericConn) *DBQuerier

NewQuerier creates a DBQuerier that implements Querier. conn is typically *pgx.Conn, pgx.Tx, or *pgxpool.Pool.

func (*DBQuerier) OutParams

func (q *DBQuerier) OutParams(ctx context.Context) ([]OutParamsRow, error)

OutParams implements Querier.OutParams.

func (*DBQuerier) OutParamsBatch

func (q *DBQuerier) OutParamsBatch(batch genericBatch)

OutParamsBatch implements Querier.OutParamsBatch.

func (*DBQuerier) OutParamsScan

func (q *DBQuerier) OutParamsScan(results pgx.BatchResults) ([]OutParamsRow, error)

OutParamsScan implements Querier.OutParamsScan.

type ListItem

type ListItem struct {
	Name  *string `json:"name"`
	Color *string `json:"color"`
}

ListItem represents the Postgres composite type "list_item".

type ListStats

type ListStats struct {
	Val1 *string  `json:"val1"`
	Val2 []*int32 `json:"val2"`
}

ListStats represents the Postgres composite type "list_stats".

type OutParamsRow

type OutParamsRow struct {
	Items []ListItem `json:"_items"`
	Stats ListStats  `json:"_stats"`
}

type Querier

type Querier interface {
	OutParams(ctx context.Context) ([]OutParamsRow, error)
	// OutParamsBatch enqueues a OutParams query into batch to be executed
	// later by the batch.
	OutParamsBatch(batch genericBatch)
	// OutParamsScan scans the result of an executed OutParamsBatch query.
	OutParamsScan(results pgx.BatchResults) ([]OutParamsRow, error)
}

Querier is a typesafe Go interface backed by SQL queries.

Methods ending with Batch enqueue a query to run later in a pgx.Batch. After calling SendBatch on pgx.Conn, pgxpool.Pool, or pgx.Tx, use the Scan methods to parse the results.

Jump to

Keyboard shortcuts

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