Documentation
¶
Index ¶
- func RegisterTypes(ctx context.Context, conn *pgx.Conn) 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)
- 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 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 (*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 ¶
func (q *DBQuerier) AlphaCompositeArrayScan(results pgx.BatchResults) ([]Alpha, error)
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 ¶
func (q *DBQuerier) AlphaNestedScan(results pgx.BatchResults) (string, error)
AlphaNestedScan implements Querier.AlphaNestedScan.
func (*DBQuerier) AlphaScan ¶
func (q *DBQuerier) AlphaScan(results pgx.BatchResults) (string, error)
AlphaScan implements Querier.AlphaScan.
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.