Documentation ¶
Index ¶
- func PrepareAllQueries(ctx context.Context, p preparer) error
- type CustomInt
- type CustomTypesRow
- type DBQuerier
- func (q *DBQuerier) CustomMyInt(ctx context.Context) (int, error)
- func (q *DBQuerier) CustomMyIntBatch(batch genericBatch)
- func (q *DBQuerier) CustomMyIntScan(results pgx.BatchResults) (int, error)
- func (q *DBQuerier) CustomTypes(ctx context.Context) (CustomTypesRow, error)
- func (q *DBQuerier) CustomTypesBatch(batch genericBatch)
- func (q *DBQuerier) CustomTypesScan(results pgx.BatchResults) (CustomTypesRow, error)
- func (q *DBQuerier) IntArray(ctx context.Context) ([][]int32, error)
- func (q *DBQuerier) IntArrayBatch(batch genericBatch)
- func (q *DBQuerier) IntArrayScan(results pgx.BatchResults) ([][]int32, 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 CustomInt ¶
type CustomInt int
CustomInt is a custom type in the same package as the query file.
type CustomTypesRow ¶
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) CustomMyInt ¶
CustomMyInt implements Querier.CustomMyInt.
func (*DBQuerier) CustomMyIntBatch ¶
func (q *DBQuerier) CustomMyIntBatch(batch genericBatch)
CustomMyIntBatch implements Querier.CustomMyIntBatch.
func (*DBQuerier) CustomMyIntScan ¶
CustomMyIntScan implements Querier.CustomMyIntScan.
func (*DBQuerier) CustomTypes ¶
func (q *DBQuerier) CustomTypes(ctx context.Context) (CustomTypesRow, error)
CustomTypes implements Querier.CustomTypes.
func (*DBQuerier) CustomTypesBatch ¶
func (q *DBQuerier) CustomTypesBatch(batch genericBatch)
CustomTypesBatch implements Querier.CustomTypesBatch.
func (*DBQuerier) CustomTypesScan ¶
func (q *DBQuerier) CustomTypesScan(results pgx.BatchResults) (CustomTypesRow, error)
CustomTypesScan implements Querier.CustomTypesScan.
func (*DBQuerier) IntArrayBatch ¶
func (q *DBQuerier) IntArrayBatch(batch genericBatch)
IntArrayBatch implements Querier.IntArrayBatch.
func (*DBQuerier) IntArrayScan ¶
IntArrayScan implements Querier.IntArrayScan.
type Querier ¶
type Querier interface { CustomTypes(ctx context.Context) (CustomTypesRow, error) // CustomTypesBatch enqueues a CustomTypes query into batch to be executed // later by the batch. CustomTypesBatch(batch genericBatch) // CustomTypesScan scans the result of an executed CustomTypesBatch query. CustomTypesScan(results pgx.BatchResults) (CustomTypesRow, error) CustomMyInt(ctx context.Context) (int, error) // CustomMyIntBatch enqueues a CustomMyInt query into batch to be executed // later by the batch. CustomMyIntBatch(batch genericBatch) // CustomMyIntScan scans the result of an executed CustomMyIntBatch query. CustomMyIntScan(results pgx.BatchResults) (int, error) IntArray(ctx context.Context) ([][]int32, error) // IntArrayBatch enqueues a IntArray query into batch to be executed // later by the batch. IntArrayBatch(batch genericBatch) // IntArrayScan scans the result of an executed IntArrayBatch query. IntArrayScan(results pgx.BatchResults) ([][]int32, 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 }