Documentation
¶
Index ¶
- func RegisterTypes(ctx context.Context, conn *pgx.Conn) 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)
- type Querier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterTypes ¶ added in v0.0.3
RegisterTypes registers custom Postgres types (composites and enums) with the pgx connection's TypeMap so that they can be scanned and encoded correctly. Call this once per connection after connecting.
For pgxpool.Pool, use config.AfterConnect:
config.AfterConnect = func(ctx context.Context, conn *pgx.Conn) error {
return RegisterTypes(ctx, conn)
}
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 (*DBQuerier) CustomMyInt ¶
CustomMyInt implements Querier.CustomMyInt.
func (*DBQuerier) CustomMyIntBatch ¶
func (q *DBQuerier) CustomMyIntBatch(batch genericBatch)
CustomMyIntBatch implements Querier.CustomMyIntBatch.
func (*DBQuerier) CustomMyIntScan ¶
func (q *DBQuerier) CustomMyIntScan(results pgx.BatchResults) (int, error)
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 ¶
func (q *DBQuerier) IntArrayScan(results pgx.BatchResults) ([][]int32, error)
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.