void

package
v0.0.0-...-c2f4e09 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MIT Imports: 5 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) VoidOnly

func (q *DBQuerier) VoidOnly(ctx context.Context) (pgconn.CommandTag, error)

VoidOnly implements Querier.VoidOnly.

func (*DBQuerier) VoidOnlyBatch

func (q *DBQuerier) VoidOnlyBatch(batch genericBatch)

VoidOnlyBatch implements Querier.VoidOnlyBatch.

func (*DBQuerier) VoidOnlyScan

func (q *DBQuerier) VoidOnlyScan(results pgx.BatchResults) (pgconn.CommandTag, error)

VoidOnlyScan implements Querier.VoidOnlyScan.

func (*DBQuerier) VoidOnlyTwoParams

func (q *DBQuerier) VoidOnlyTwoParams(ctx context.Context, id int32) (pgconn.CommandTag, error)

VoidOnlyTwoParams implements Querier.VoidOnlyTwoParams.

func (*DBQuerier) VoidOnlyTwoParamsBatch

func (q *DBQuerier) VoidOnlyTwoParamsBatch(batch genericBatch, id int32)

VoidOnlyTwoParamsBatch implements Querier.VoidOnlyTwoParamsBatch.

func (*DBQuerier) VoidOnlyTwoParamsScan

func (q *DBQuerier) VoidOnlyTwoParamsScan(results pgx.BatchResults) (pgconn.CommandTag, error)

VoidOnlyTwoParamsScan implements Querier.VoidOnlyTwoParamsScan.

func (*DBQuerier) VoidThree

func (q *DBQuerier) VoidThree(ctx context.Context) (VoidThreeRow, error)

VoidThree implements Querier.VoidThree.

func (*DBQuerier) VoidThree2

func (q *DBQuerier) VoidThree2(ctx context.Context) ([]string, error)

VoidThree2 implements Querier.VoidThree2.

func (*DBQuerier) VoidThree2Batch

func (q *DBQuerier) VoidThree2Batch(batch genericBatch)

VoidThree2Batch implements Querier.VoidThree2Batch.

func (*DBQuerier) VoidThree2Scan

func (q *DBQuerier) VoidThree2Scan(results pgx.BatchResults) ([]string, error)

VoidThree2Scan implements Querier.VoidThree2Scan.

func (*DBQuerier) VoidThreeBatch

func (q *DBQuerier) VoidThreeBatch(batch genericBatch)

VoidThreeBatch implements Querier.VoidThreeBatch.

func (*DBQuerier) VoidThreeScan

func (q *DBQuerier) VoidThreeScan(results pgx.BatchResults) (VoidThreeRow, error)

VoidThreeScan implements Querier.VoidThreeScan.

func (*DBQuerier) VoidTwo

func (q *DBQuerier) VoidTwo(ctx context.Context) (string, error)

VoidTwo implements Querier.VoidTwo.

func (*DBQuerier) VoidTwoBatch

func (q *DBQuerier) VoidTwoBatch(batch genericBatch)

VoidTwoBatch implements Querier.VoidTwoBatch.

func (*DBQuerier) VoidTwoScan

func (q *DBQuerier) VoidTwoScan(results pgx.BatchResults) (string, error)

VoidTwoScan implements Querier.VoidTwoScan.

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 {
	VoidOnly(ctx context.Context) (pgconn.CommandTag, error)
	// VoidOnlyBatch enqueues a VoidOnly query into batch to be executed
	// later by the batch.
	VoidOnlyBatch(batch genericBatch)
	// VoidOnlyScan scans the result of an executed VoidOnlyBatch query.
	VoidOnlyScan(results pgx.BatchResults) (pgconn.CommandTag, error)

	VoidOnlyTwoParams(ctx context.Context, id int32) (pgconn.CommandTag, error)
	// VoidOnlyTwoParamsBatch enqueues a VoidOnlyTwoParams query into batch to be executed
	// later by the batch.
	VoidOnlyTwoParamsBatch(batch genericBatch, id int32)
	// VoidOnlyTwoParamsScan scans the result of an executed VoidOnlyTwoParamsBatch query.
	VoidOnlyTwoParamsScan(results pgx.BatchResults) (pgconn.CommandTag, error)

	VoidTwo(ctx context.Context) (string, error)
	// VoidTwoBatch enqueues a VoidTwo query into batch to be executed
	// later by the batch.
	VoidTwoBatch(batch genericBatch)
	// VoidTwoScan scans the result of an executed VoidTwoBatch query.
	VoidTwoScan(results pgx.BatchResults) (string, error)

	VoidThree(ctx context.Context) (VoidThreeRow, error)
	// VoidThreeBatch enqueues a VoidThree query into batch to be executed
	// later by the batch.
	VoidThreeBatch(batch genericBatch)
	// VoidThreeScan scans the result of an executed VoidThreeBatch query.
	VoidThreeScan(results pgx.BatchResults) (VoidThreeRow, error)

	VoidThree2(ctx context.Context) ([]string, error)
	// VoidThree2Batch enqueues a VoidThree2 query into batch to be executed
	// later by the batch.
	VoidThree2Batch(batch genericBatch)
	// VoidThree2Scan scans the result of an executed VoidThree2Batch query.
	VoidThree2Scan(results pgx.BatchResults) ([]string, 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
}

type VoidThreeRow

type VoidThreeRow struct {
	Foo string `json:"foo"`
	Bar string `json:"bar"`
}

Jump to

Keyboard shortcuts

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