Documentation ¶
Index ¶
- func PrepareAllQueries(ctx context.Context, p preparer) error
- type Alpha
- type DBQuerier
- func (q *DBQuerier) Alpha(ctx context.Context) (string, error)
- func (q *DBQuerier) AlphaBatch(batch genericBatch)
- func (q *DBQuerier) AlphaCompositeArray(ctx context.Context) ([]Alpha, error)
- func (q *DBQuerier) AlphaCompositeArrayBatch(batch genericBatch)
- func (q *DBQuerier) AlphaCompositeArrayScan(results pgx.BatchResults) ([]Alpha, error)
- func (q *DBQuerier) AlphaNested(ctx context.Context) (string, error)
- func (q *DBQuerier) AlphaNestedBatch(batch genericBatch)
- func (q *DBQuerier) AlphaNestedScan(results pgx.BatchResults) (string, error)
- func (q *DBQuerier) AlphaScan(results pgx.BatchResults) (string, error)
- func (q *DBQuerier) Bravo(ctx context.Context) (string, error)
- func (q *DBQuerier) BravoBatch(batch genericBatch)
- func (q *DBQuerier) BravoScan(results pgx.BatchResults) (string, 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 sqlgen 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 Alpha ¶
type Alpha struct {
Key *string `json:"key"`
}
Alpha represents the Postgres composite type "alpha".
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) AlphaBatch ¶
func (q *DBQuerier) AlphaBatch(batch genericBatch)
AlphaBatch implements Querier.AlphaBatch.
func (*DBQuerier) AlphaCompositeArray ¶
AlphaCompositeArray implements Querier.AlphaCompositeArray.
func (*DBQuerier) AlphaCompositeArrayBatch ¶
func (q *DBQuerier) AlphaCompositeArrayBatch(batch genericBatch)
AlphaCompositeArrayBatch implements Querier.AlphaCompositeArrayBatch.
func (*DBQuerier) AlphaCompositeArrayScan ¶
AlphaCompositeArrayScan implements Querier.AlphaCompositeArrayScan.
func (*DBQuerier) AlphaNested ¶
AlphaNested implements Querier.AlphaNested.
func (*DBQuerier) AlphaNestedBatch ¶
func (q *DBQuerier) AlphaNestedBatch(batch genericBatch)
AlphaNestedBatch implements Querier.AlphaNestedBatch.
func (*DBQuerier) AlphaNestedScan ¶
AlphaNestedScan implements Querier.AlphaNestedScan.
func (*DBQuerier) BravoBatch ¶
func (q *DBQuerier) BravoBatch(batch genericBatch)
BravoBatch implements Querier.BravoBatch.
type Querier ¶
type Querier interface { AlphaNested(ctx context.Context) (string, error) // AlphaNestedBatch enqueues a AlphaNested query into batch to be executed // later by the batch. AlphaNestedBatch(batch genericBatch) // AlphaNestedScan scans the result of an executed AlphaNestedBatch query. AlphaNestedScan(results pgx.BatchResults) (string, error) AlphaCompositeArray(ctx context.Context) ([]Alpha, error) // AlphaCompositeArrayBatch enqueues a AlphaCompositeArray query into batch to be executed // later by the batch. AlphaCompositeArrayBatch(batch genericBatch) // AlphaCompositeArrayScan scans the result of an executed AlphaCompositeArrayBatch query. AlphaCompositeArrayScan(results pgx.BatchResults) ([]Alpha, error) Alpha(ctx context.Context) (string, error) // AlphaBatch enqueues a Alpha query into batch to be executed // later by the batch. AlphaBatch(batch genericBatch) // AlphaScan scans the result of an executed AlphaBatch query. AlphaScan(results pgx.BatchResults) (string, error) Bravo(ctx context.Context) (string, error) // BravoBatch enqueues a Bravo query into batch to be executed // later by the batch. BravoBatch(batch genericBatch) // BravoScan scans the result of an executed BravoBatch query. BravoScan(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 sqlgen-generated pgtype.ValueTranscoder. // // If OIDs are available for an input parameter type and all of its // transitive dependencies, sqlgen will use the binary encoding format for // the input parameter. DataTypes []pgtype.DataType }