slices

package
v0.0.0-...-765d1ad Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareAllQueries

func PrepareAllQueries(ctx context.Context, p preparer) error

PrepareAllQueries executes a PREPARE statement for all pggen generated SQL queries in querier files. Typical usage is as the AfterConnect callback for pgxpool.Config

pgx will use the prepared statement if available. Calling PrepareAllQueries is an optional optimization to avoid a network round-trip the first time pgx runs a query if pgx statement caching is enabled.

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 NewQuerierConfig

func NewQuerierConfig(conn genericConn, cfg QuerierConfig) *DBQuerier

NewQuerierConfig creates a DBQuerier that implements Querier with the given config. 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.

func (*DBQuerier) WithTx

func (q *DBQuerier) WithTx(tx pgx.Tx) (*DBQuerier, error)

WithTx creates a new DBQuerier that uses the transaction to run all queries.

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.

type QuerierConfig

type QuerierConfig struct {
	// DataTypes contains pgtype.Value to use for encoding and decoding instead
	// of pggen-generated pgtype.ValueTranscoder.
	//
	// If OIDs are available for an input parameter type and all of its
	// transitive dependencies, pggen will use the binary encoding format for
	// the input parameter.
	DataTypes []pgtype.DataType
}

Jump to

Keyboard shortcuts

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