Documentation ¶
Index ¶
- func PrepareAllQueries(ctx context.Context, p preparer) error
- type DBQuerier
- func (q *DBQuerier) VoidOnly(ctx context.Context) (pgconn.CommandTag, error)
- func (q *DBQuerier) VoidOnlyBatch(batch genericBatch)
- func (q *DBQuerier) VoidOnlyScan(results pgx.BatchResults) (pgconn.CommandTag, error)
- func (q *DBQuerier) VoidOnlyTwoParams(ctx context.Context, id int32) (pgconn.CommandTag, error)
- func (q *DBQuerier) VoidOnlyTwoParamsBatch(batch genericBatch, id int32)
- func (q *DBQuerier) VoidOnlyTwoParamsScan(results pgx.BatchResults) (pgconn.CommandTag, error)
- func (q *DBQuerier) VoidThree(ctx context.Context) (VoidThreeRow, error)
- func (q *DBQuerier) VoidThree2(ctx context.Context) ([]string, error)
- func (q *DBQuerier) VoidThree2Batch(batch genericBatch)
- func (q *DBQuerier) VoidThree2Scan(results pgx.BatchResults) ([]string, error)
- func (q *DBQuerier) VoidThreeBatch(batch genericBatch)
- func (q *DBQuerier) VoidThreeScan(results pgx.BatchResults) (VoidThreeRow, error)
- func (q *DBQuerier) VoidTwo(ctx context.Context) (string, error)
- func (q *DBQuerier) VoidTwoBatch(batch genericBatch)
- func (q *DBQuerier) VoidTwoScan(results pgx.BatchResults) (string, error)
- func (q *DBQuerier) WithTx(tx pgx.Tx) (*DBQuerier, error)
- type Querier
- type QuerierConfig
- type VoidThreeRow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrepareAllQueries ¶
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) 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 ¶
VoidOnlyTwoParams implements Querier.VoidOnlyTwoParams.
func (*DBQuerier) VoidOnlyTwoParamsBatch ¶
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 ¶
VoidThree2 implements Querier.VoidThree2.
func (*DBQuerier) VoidThree2Batch ¶
func (q *DBQuerier) VoidThree2Batch(batch genericBatch)
VoidThree2Batch implements Querier.VoidThree2Batch.
func (*DBQuerier) VoidThree2Scan ¶
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) VoidTwoBatch ¶
func (q *DBQuerier) VoidTwoBatch(batch genericBatch)
VoidTwoBatch implements Querier.VoidTwoBatch.
func (*DBQuerier) VoidTwoScan ¶
VoidTwoScan implements Querier.VoidTwoScan.
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 }