Documentation ¶
Index ¶
- func PrepareAllQueries(ctx context.Context, p preparer) error
- type DBQuerier
- func (q *DBQuerier) FindNumerics(ctx context.Context) ([]FindNumericsRow, error)
- func (q *DBQuerier) FindNumericsBatch(batch genericBatch)
- func (q *DBQuerier) FindNumericsScan(results pgx.BatchResults) ([]FindNumericsRow, error)
- func (q *DBQuerier) InsertNumeric(ctx context.Context, num decimal.Decimal, numArr []NumericExternalType) (pgconn.CommandTag, error)
- func (q *DBQuerier) InsertNumericBatch(batch genericBatch, num decimal.Decimal, numArr []NumericExternalType)
- func (q *DBQuerier) InsertNumericScan(results pgx.BatchResults) (pgconn.CommandTag, error)
- func (q *DBQuerier) WithTx(tx pgx.Tx) (*DBQuerier, error)
- type FindNumericsRow
- type NumericExternalType
- 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) FindNumerics ¶
func (q *DBQuerier) FindNumerics(ctx context.Context) ([]FindNumericsRow, error)
FindNumerics implements Querier.FindNumerics.
func (*DBQuerier) FindNumericsBatch ¶
func (q *DBQuerier) FindNumericsBatch(batch genericBatch)
FindNumericsBatch implements Querier.FindNumericsBatch.
func (*DBQuerier) FindNumericsScan ¶
func (q *DBQuerier) FindNumericsScan(results pgx.BatchResults) ([]FindNumericsRow, error)
FindNumericsScan implements Querier.FindNumericsScan.
func (*DBQuerier) InsertNumeric ¶
func (q *DBQuerier) InsertNumeric(ctx context.Context, num decimal.Decimal, numArr []NumericExternalType) (pgconn.CommandTag, error)
InsertNumeric implements Querier.InsertNumeric.
func (*DBQuerier) InsertNumericBatch ¶
func (q *DBQuerier) InsertNumericBatch(batch genericBatch, num decimal.Decimal, numArr []NumericExternalType)
InsertNumericBatch implements Querier.InsertNumericBatch.
func (*DBQuerier) InsertNumericScan ¶
func (q *DBQuerier) InsertNumericScan(results pgx.BatchResults) (pgconn.CommandTag, error)
InsertNumericScan implements Querier.InsertNumericScan.
type FindNumericsRow ¶
type FindNumericsRow struct { Num decimal.Decimal `json:"num"` NumArr []NumericExternalType `json:"num_arr"` }
type NumericExternalType ¶
NumericExternalType represents the Postgres composite type "numeric_external_type".
type Querier ¶
type Querier interface { InsertNumeric(ctx context.Context, num decimal.Decimal, numArr []NumericExternalType) (pgconn.CommandTag, error) // InsertNumericBatch enqueues a InsertNumeric query into batch to be executed // later by the batch. InsertNumericBatch(batch genericBatch, num decimal.Decimal, numArr []NumericExternalType) // InsertNumericScan scans the result of an executed InsertNumericBatch query. InsertNumericScan(results pgx.BatchResults) (pgconn.CommandTag, error) FindNumerics(ctx context.Context) ([]FindNumericsRow, error) // FindNumericsBatch enqueues a FindNumerics query into batch to be executed // later by the batch. FindNumericsBatch(batch genericBatch) // FindNumericsScan scans the result of an executed FindNumericsBatch query. FindNumericsScan(results pgx.BatchResults) ([]FindNumericsRow, 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 }