slices

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: 5 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) GetBools

func (q *DBQuerier) GetBools(ctx context.Context, data []bool) ([]bool, error)

GetBools implements Querier.GetBools.

func (*DBQuerier) GetBoolsBatch

func (q *DBQuerier) GetBoolsBatch(batch genericBatch, data []bool)

GetBoolsBatch implements Querier.GetBoolsBatch.

func (*DBQuerier) GetBoolsScan

func (q *DBQuerier) GetBoolsScan(results pgx.BatchResults) ([]bool, error)

GetBoolsScan implements Querier.GetBoolsScan.

func (*DBQuerier) GetManyTimestamps

func (q *DBQuerier) GetManyTimestamps(ctx context.Context, data []*time.Time) ([]*time.Time, error)

GetManyTimestamps implements Querier.GetManyTimestamps.

func (*DBQuerier) GetManyTimestampsBatch

func (q *DBQuerier) GetManyTimestampsBatch(batch genericBatch, data []*time.Time)

GetManyTimestampsBatch implements Querier.GetManyTimestampsBatch.

func (*DBQuerier) GetManyTimestampsScan

func (q *DBQuerier) GetManyTimestampsScan(results pgx.BatchResults) ([]*time.Time, error)

GetManyTimestampsScan implements Querier.GetManyTimestampsScan.

func (*DBQuerier) GetManyTimestamptzs

func (q *DBQuerier) GetManyTimestamptzs(ctx context.Context, data []time.Time) ([]*time.Time, error)

GetManyTimestamptzs implements Querier.GetManyTimestamptzs.

func (*DBQuerier) GetManyTimestamptzsBatch

func (q *DBQuerier) GetManyTimestamptzsBatch(batch genericBatch, data []time.Time)

GetManyTimestamptzsBatch implements Querier.GetManyTimestamptzsBatch.

func (*DBQuerier) GetManyTimestamptzsScan

func (q *DBQuerier) GetManyTimestamptzsScan(results pgx.BatchResults) ([]*time.Time, error)

GetManyTimestamptzsScan implements Querier.GetManyTimestamptzsScan.

func (*DBQuerier) GetOneTimestamp

func (q *DBQuerier) GetOneTimestamp(ctx context.Context, data *time.Time) (*time.Time, error)

GetOneTimestamp implements Querier.GetOneTimestamp.

func (*DBQuerier) GetOneTimestampBatch

func (q *DBQuerier) GetOneTimestampBatch(batch genericBatch, data *time.Time)

GetOneTimestampBatch implements Querier.GetOneTimestampBatch.

func (*DBQuerier) GetOneTimestampScan

func (q *DBQuerier) GetOneTimestampScan(results pgx.BatchResults) (*time.Time, error)

GetOneTimestampScan implements Querier.GetOneTimestampScan.

type Querier

type Querier interface {
	GetBools(ctx context.Context, data []bool) ([]bool, error)
	// GetBoolsBatch enqueues a GetBools query into batch to be executed
	// later by the batch.
	GetBoolsBatch(batch genericBatch, data []bool)
	// GetBoolsScan scans the result of an executed GetBoolsBatch query.
	GetBoolsScan(results pgx.BatchResults) ([]bool, error)

	GetOneTimestamp(ctx context.Context, data *time.Time) (*time.Time, error)
	// GetOneTimestampBatch enqueues a GetOneTimestamp query into batch to be executed
	// later by the batch.
	GetOneTimestampBatch(batch genericBatch, data *time.Time)
	// GetOneTimestampScan scans the result of an executed GetOneTimestampBatch query.
	GetOneTimestampScan(results pgx.BatchResults) (*time.Time, error)

	GetManyTimestamptzs(ctx context.Context, data []time.Time) ([]*time.Time, error)
	// GetManyTimestamptzsBatch enqueues a GetManyTimestamptzs query into batch to be executed
	// later by the batch.
	GetManyTimestamptzsBatch(batch genericBatch, data []time.Time)
	// GetManyTimestamptzsScan scans the result of an executed GetManyTimestamptzsBatch query.
	GetManyTimestamptzsScan(results pgx.BatchResults) ([]*time.Time, error)

	GetManyTimestamps(ctx context.Context, data []*time.Time) ([]*time.Time, error)
	// GetManyTimestampsBatch enqueues a GetManyTimestamps query into batch to be executed
	// later by the batch.
	GetManyTimestampsBatch(batch genericBatch, data []*time.Time)
	// GetManyTimestampsScan scans the result of an executed GetManyTimestampsBatch query.
	GetManyTimestampsScan(results pgx.BatchResults) ([]*time.Time, 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