Documentation ¶
Index ¶
- func PrepareAllQueries(ctx context.Context, p preparer) error
- type DBQuerier
- func (q *DBQuerier) GetBools(ctx context.Context, data []bool) ([]bool, error)
- func (q *DBQuerier) GetBoolsBatch(batch genericBatch, data []bool)
- func (q *DBQuerier) GetBoolsScan(results pgx.BatchResults) ([]bool, error)
- func (q *DBQuerier) GetManyTimestamps(ctx context.Context, data []*time.Time) ([]*time.Time, error)
- func (q *DBQuerier) GetManyTimestampsBatch(batch genericBatch, data []*time.Time)
- func (q *DBQuerier) GetManyTimestampsScan(results pgx.BatchResults) ([]*time.Time, error)
- func (q *DBQuerier) GetManyTimestamptzs(ctx context.Context, data []time.Time) ([]*time.Time, error)
- func (q *DBQuerier) GetManyTimestamptzsBatch(batch genericBatch, data []time.Time)
- func (q *DBQuerier) GetManyTimestamptzsScan(results pgx.BatchResults) ([]*time.Time, error)
- func (q *DBQuerier) GetOneTimestamp(ctx context.Context, data *time.Time) (*time.Time, error)
- func (q *DBQuerier) GetOneTimestampBatch(batch genericBatch, data *time.Time)
- func (q *DBQuerier) GetOneTimestampScan(results pgx.BatchResults) (*time.Time, error)
- func (q *DBQuerier) WithTx(tx pgx.Tx) (*DBQuerier, error)
- type Querier
- type QuerierConfig
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) GetBoolsBatch ¶
GetBoolsBatch implements Querier.GetBoolsBatch.
func (*DBQuerier) GetBoolsScan ¶
GetBoolsScan implements Querier.GetBoolsScan.
func (*DBQuerier) GetManyTimestamps ¶
GetManyTimestamps implements Querier.GetManyTimestamps.
func (*DBQuerier) GetManyTimestampsBatch ¶
GetManyTimestampsBatch implements Querier.GetManyTimestampsBatch.
func (*DBQuerier) GetManyTimestampsScan ¶
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 ¶
GetManyTimestamptzsBatch implements Querier.GetManyTimestamptzsBatch.
func (*DBQuerier) GetManyTimestamptzsScan ¶
GetManyTimestamptzsScan implements Querier.GetManyTimestamptzsScan.
func (*DBQuerier) GetOneTimestamp ¶
GetOneTimestamp implements Querier.GetOneTimestamp.
func (*DBQuerier) GetOneTimestampBatch ¶
GetOneTimestampBatch implements Querier.GetOneTimestampBatch.
func (*DBQuerier) GetOneTimestampScan ¶
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.
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 }