Documentation
¶
Index ¶
- func PrepareAllQueries(ctx context.Context, p preparer) error
- type Connection
- type DBQuerier
- func (q *DBQuerier) GroupByID(ctx context.Context, id int) (GroupByIDRow, error)
- func (q *DBQuerier) GroupByIDBatch(batch genericBatch, id int)
- func (q *DBQuerier) GroupByIDScan(results pgx.BatchResults) (GroupByIDRow, error)
- func (q *DBQuerier) IDByGroup(ctx context.Context, params IDByGroupParams) (int, error)
- func (q *DBQuerier) IDByGroupBatch(batch genericBatch, params IDByGroupParams)
- func (q *DBQuerier) IDByGroupScan(results pgx.BatchResults) (int, error)
- func (q *DBQuerier) SelectNumsForYearAndSpec(ctx context.Context, year int, spec pgtype.Text) ([]int, error)
- func (q *DBQuerier) SelectNumsForYearAndSpecBatch(batch genericBatch, year int, spec pgtype.Text)
- func (q *DBQuerier) SelectNumsForYearAndSpecScan(results pgx.BatchResults) ([]int, error)
- func (q *DBQuerier) SelectSpecsForYear(ctx context.Context, year int) ([]pgtype.Text, error)
- func (q *DBQuerier) SelectSpecsForYearBatch(batch genericBatch, year int)
- func (q *DBQuerier) SelectSpecsForYearScan(results pgx.BatchResults) ([]pgtype.Text, error)
- func (q *DBQuerier) SelectYears(ctx context.Context) ([]int, error)
- func (q *DBQuerier) SelectYearsBatch(batch genericBatch)
- func (q *DBQuerier) SelectYearsScan(results pgx.BatchResults) ([]int, error)
- func (q *DBQuerier) WithTx(tx pgx.Tx) (*DBQuerier, error)
- type GroupByIDRow
- type IDByGroupParams
- type Querier
- type QuerierConfig
- type Repository
- func (r *Repository) FindByID(ctx context.Context, id int) (group.Group, error)
- func (r *Repository) FindID(ctx context.Context, params group.Group) (int, error)
- func (r *Repository) Nums(ctx context.Context, year int, spec string) ([]int, error)
- func (r *Repository) Specs(ctx context.Context, year int) ([]string, error)
- func (r *Repository) Years(ctx context.Context) ([]int, error)
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 Connection ¶
type Connection genericConn
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) GroupByIDBatch ¶
GroupByIDBatch implements Querier.GroupByIDBatch.
func (*DBQuerier) GroupByIDScan ¶
func (q *DBQuerier) GroupByIDScan(results pgx.BatchResults) (GroupByIDRow, error)
GroupByIDScan implements Querier.GroupByIDScan.
func (*DBQuerier) IDByGroupBatch ¶
func (q *DBQuerier) IDByGroupBatch(batch genericBatch, params IDByGroupParams)
IDByGroupBatch implements Querier.IDByGroupBatch.
func (*DBQuerier) IDByGroupScan ¶
IDByGroupScan implements Querier.IDByGroupScan.
func (*DBQuerier) SelectNumsForYearAndSpec ¶
func (q *DBQuerier) SelectNumsForYearAndSpec(ctx context.Context, year int, spec pgtype.Text) ([]int, error)
SelectNumsForYearAndSpec implements Querier.SelectNumsForYearAndSpec.
func (*DBQuerier) SelectNumsForYearAndSpecBatch ¶
SelectNumsForYearAndSpecBatch implements Querier.SelectNumsForYearAndSpecBatch.
func (*DBQuerier) SelectNumsForYearAndSpecScan ¶
SelectNumsForYearAndSpecScan implements Querier.SelectNumsForYearAndSpecScan.
func (*DBQuerier) SelectSpecsForYear ¶
SelectSpecsForYear implements Querier.SelectSpecsForYear.
func (*DBQuerier) SelectSpecsForYearBatch ¶
SelectSpecsForYearBatch implements Querier.SelectSpecsForYearBatch.
func (*DBQuerier) SelectSpecsForYearScan ¶
SelectSpecsForYearScan implements Querier.SelectSpecsForYearScan.
func (*DBQuerier) SelectYears ¶
SelectYears implements Querier.SelectYears.
func (*DBQuerier) SelectYearsBatch ¶
func (q *DBQuerier) SelectYearsBatch(batch genericBatch)
SelectYearsBatch implements Querier.SelectYearsBatch.
func (*DBQuerier) SelectYearsScan ¶
SelectYearsScan implements Querier.SelectYearsScan.
type GroupByIDRow ¶
type Querier ¶
type Querier interface { GroupByID(ctx context.Context, id int) (GroupByIDRow, error) // GroupByIDBatch enqueues a GroupByID query into batch to be executed // later by the batch. GroupByIDBatch(batch genericBatch, id int) // GroupByIDScan scans the result of an executed GroupByIDBatch query. GroupByIDScan(results pgx.BatchResults) (GroupByIDRow, error) IDByGroup(ctx context.Context, params IDByGroupParams) (int, error) // IDByGroupBatch enqueues a IDByGroup query into batch to be executed // later by the batch. IDByGroupBatch(batch genericBatch, params IDByGroupParams) // IDByGroupScan scans the result of an executed IDByGroupBatch query. IDByGroupScan(results pgx.BatchResults) (int, error) SelectYears(ctx context.Context) ([]int, error) // SelectYearsBatch enqueues a SelectYears query into batch to be executed // later by the batch. SelectYearsBatch(batch genericBatch) // SelectYearsScan scans the result of an executed SelectYearsBatch query. SelectYearsScan(results pgx.BatchResults) ([]int, error) SelectSpecsForYear(ctx context.Context, year int) ([]pgtype.Text, error) // SelectSpecsForYearBatch enqueues a SelectSpecsForYear query into batch to be executed // later by the batch. SelectSpecsForYearBatch(batch genericBatch, year int) // SelectSpecsForYearScan scans the result of an executed SelectSpecsForYearBatch query. SelectSpecsForYearScan(results pgx.BatchResults) ([]pgtype.Text, error) SelectNumsForYearAndSpec(ctx context.Context, year int, spec pgtype.Text) ([]int, error) // SelectNumsForYearAndSpecBatch enqueues a SelectNumsForYearAndSpec query into batch to be executed // later by the batch. SelectNumsForYearAndSpecBatch(batch genericBatch, year int, spec pgtype.Text) // SelectNumsForYearAndSpecScan scans the result of an executed SelectNumsForYearAndSpecBatch query. SelectNumsForYearAndSpecScan(results pgx.BatchResults) ([]int, 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 }
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func NewRepository ¶
func NewRepository(conn Connection) *Repository