Documentation
¶
Index ¶
- func PrepareAllQueries(ctx context.Context, p preparer) error
- type DBQuerier
- func (q *DBQuerier) ArrayAggFirstName(ctx context.Context, authorID int32) ([]string, error)
- func (q *DBQuerier) ArrayAggFirstNameBatch(batch genericBatch, authorID int32)
- func (q *DBQuerier) ArrayAggFirstNameScan(results pgx.BatchResults) ([]string, error)
- func (q *DBQuerier) DeleteAuthors(ctx context.Context) (pgconn.CommandTag, error)
- func (q *DBQuerier) DeleteAuthorsBatch(batch genericBatch)
- func (q *DBQuerier) DeleteAuthorsByFirstName(ctx context.Context, firstName string) (pgconn.CommandTag, error)
- func (q *DBQuerier) DeleteAuthorsByFirstNameBatch(batch genericBatch, firstName string)
- func (q *DBQuerier) DeleteAuthorsByFirstNameScan(results pgx.BatchResults) (pgconn.CommandTag, error)
- func (q *DBQuerier) DeleteAuthorsByFullName(ctx context.Context, params DeleteAuthorsByFullNameParams) (pgconn.CommandTag, error)
- func (q *DBQuerier) DeleteAuthorsByFullNameBatch(batch genericBatch, params DeleteAuthorsByFullNameParams)
- func (q *DBQuerier) DeleteAuthorsByFullNameScan(results pgx.BatchResults) (pgconn.CommandTag, error)
- func (q *DBQuerier) DeleteAuthorsScan(results pgx.BatchResults) (pgconn.CommandTag, error)
- func (q *DBQuerier) FindAuthorByID(ctx context.Context, authorID int32) (FindAuthorByIDRow, error)
- func (q *DBQuerier) FindAuthorByIDBatch(batch genericBatch, authorID int32)
- func (q *DBQuerier) FindAuthorByIDScan(results pgx.BatchResults) (FindAuthorByIDRow, error)
- func (q *DBQuerier) FindAuthorNames(ctx context.Context, authorID int32) ([]FindAuthorNamesRow, error)
- func (q *DBQuerier) FindAuthorNamesBatch(batch genericBatch, authorID int32)
- func (q *DBQuerier) FindAuthorNamesScan(results pgx.BatchResults) ([]FindAuthorNamesRow, error)
- func (q *DBQuerier) FindAuthors(ctx context.Context, firstName string) ([]FindAuthorsRow, error)
- func (q *DBQuerier) FindAuthorsBatch(batch genericBatch, firstName string)
- func (q *DBQuerier) FindAuthorsScan(results pgx.BatchResults) ([]FindAuthorsRow, error)
- func (q *DBQuerier) FindFirstNames(ctx context.Context, authorID int32) ([]*string, error)
- func (q *DBQuerier) FindFirstNamesBatch(batch genericBatch, authorID int32)
- func (q *DBQuerier) FindFirstNamesScan(results pgx.BatchResults) ([]*string, error)
- func (q *DBQuerier) InsertAuthor(ctx context.Context, firstName string, lastName string) (int32, error)
- func (q *DBQuerier) InsertAuthorBatch(batch genericBatch, firstName string, lastName string)
- func (q *DBQuerier) InsertAuthorScan(results pgx.BatchResults) (int32, error)
- func (q *DBQuerier) InsertAuthorSuffix(ctx context.Context, params InsertAuthorSuffixParams) (InsertAuthorSuffixRow, error)
- func (q *DBQuerier) InsertAuthorSuffixBatch(batch genericBatch, params InsertAuthorSuffixParams)
- func (q *DBQuerier) InsertAuthorSuffixScan(results pgx.BatchResults) (InsertAuthorSuffixRow, error)
- func (q *DBQuerier) StringAggFirstName(ctx context.Context, authorID int32) (*string, error)
- func (q *DBQuerier) StringAggFirstNameBatch(batch genericBatch, authorID int32)
- func (q *DBQuerier) StringAggFirstNameScan(results pgx.BatchResults) (*string, error)
- func (q *DBQuerier) WithTx(tx pgx.Tx) (*DBQuerier, error)
- type DeleteAuthorsByFullNameParams
- type FindAuthorByIDRow
- type FindAuthorNamesRow
- type FindAuthorsRow
- type InsertAuthorSuffixParams
- type InsertAuthorSuffixRow
- type Querier
- type QuerierConfig
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 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) ArrayAggFirstName ¶
ArrayAggFirstName implements Querier.ArrayAggFirstName.
func (*DBQuerier) ArrayAggFirstNameBatch ¶
ArrayAggFirstNameBatch implements Querier.ArrayAggFirstNameBatch.
func (*DBQuerier) ArrayAggFirstNameScan ¶
ArrayAggFirstNameScan implements Querier.ArrayAggFirstNameScan.
func (*DBQuerier) DeleteAuthors ¶
DeleteAuthors implements Querier.DeleteAuthors.
func (*DBQuerier) DeleteAuthorsBatch ¶
func (q *DBQuerier) DeleteAuthorsBatch(batch genericBatch)
DeleteAuthorsBatch implements Querier.DeleteAuthorsBatch.
func (*DBQuerier) DeleteAuthorsByFirstName ¶
func (q *DBQuerier) DeleteAuthorsByFirstName(ctx context.Context, firstName string) (pgconn.CommandTag, error)
DeleteAuthorsByFirstName implements Querier.DeleteAuthorsByFirstName.
func (*DBQuerier) DeleteAuthorsByFirstNameBatch ¶
DeleteAuthorsByFirstNameBatch implements Querier.DeleteAuthorsByFirstNameBatch.
func (*DBQuerier) DeleteAuthorsByFirstNameScan ¶
func (q *DBQuerier) DeleteAuthorsByFirstNameScan(results pgx.BatchResults) (pgconn.CommandTag, error)
DeleteAuthorsByFirstNameScan implements Querier.DeleteAuthorsByFirstNameScan.
func (*DBQuerier) DeleteAuthorsByFullName ¶
func (q *DBQuerier) DeleteAuthorsByFullName(ctx context.Context, params DeleteAuthorsByFullNameParams) (pgconn.CommandTag, error)
DeleteAuthorsByFullName implements Querier.DeleteAuthorsByFullName.
func (*DBQuerier) DeleteAuthorsByFullNameBatch ¶
func (q *DBQuerier) DeleteAuthorsByFullNameBatch(batch genericBatch, params DeleteAuthorsByFullNameParams)
DeleteAuthorsByFullNameBatch implements Querier.DeleteAuthorsByFullNameBatch.
func (*DBQuerier) DeleteAuthorsByFullNameScan ¶
func (q *DBQuerier) DeleteAuthorsByFullNameScan(results pgx.BatchResults) (pgconn.CommandTag, error)
DeleteAuthorsByFullNameScan implements Querier.DeleteAuthorsByFullNameScan.
func (*DBQuerier) DeleteAuthorsScan ¶
func (q *DBQuerier) DeleteAuthorsScan(results pgx.BatchResults) (pgconn.CommandTag, error)
DeleteAuthorsScan implements Querier.DeleteAuthorsScan.
func (*DBQuerier) FindAuthorByID ¶
FindAuthorByID implements Querier.FindAuthorByID.
func (*DBQuerier) FindAuthorByIDBatch ¶
FindAuthorByIDBatch implements Querier.FindAuthorByIDBatch.
func (*DBQuerier) FindAuthorByIDScan ¶
func (q *DBQuerier) FindAuthorByIDScan(results pgx.BatchResults) (FindAuthorByIDRow, error)
FindAuthorByIDScan implements Querier.FindAuthorByIDScan.
func (*DBQuerier) FindAuthorNames ¶
func (q *DBQuerier) FindAuthorNames(ctx context.Context, authorID int32) ([]FindAuthorNamesRow, error)
FindAuthorNames implements Querier.FindAuthorNames.
func (*DBQuerier) FindAuthorNamesBatch ¶
FindAuthorNamesBatch implements Querier.FindAuthorNamesBatch.
func (*DBQuerier) FindAuthorNamesScan ¶
func (q *DBQuerier) FindAuthorNamesScan(results pgx.BatchResults) ([]FindAuthorNamesRow, error)
FindAuthorNamesScan implements Querier.FindAuthorNamesScan.
func (*DBQuerier) FindAuthors ¶
FindAuthors implements Querier.FindAuthors.
func (*DBQuerier) FindAuthorsBatch ¶
FindAuthorsBatch implements Querier.FindAuthorsBatch.
func (*DBQuerier) FindAuthorsScan ¶
func (q *DBQuerier) FindAuthorsScan(results pgx.BatchResults) ([]FindAuthorsRow, error)
FindAuthorsScan implements Querier.FindAuthorsScan.
func (*DBQuerier) FindFirstNames ¶
FindFirstNames implements Querier.FindFirstNames.
func (*DBQuerier) FindFirstNamesBatch ¶
FindFirstNamesBatch implements Querier.FindFirstNamesBatch.
func (*DBQuerier) FindFirstNamesScan ¶
FindFirstNamesScan implements Querier.FindFirstNamesScan.
func (*DBQuerier) InsertAuthor ¶
func (q *DBQuerier) InsertAuthor(ctx context.Context, firstName string, lastName string) (int32, error)
InsertAuthor implements Querier.InsertAuthor.
func (*DBQuerier) InsertAuthorBatch ¶
InsertAuthorBatch implements Querier.InsertAuthorBatch.
func (*DBQuerier) InsertAuthorScan ¶
InsertAuthorScan implements Querier.InsertAuthorScan.
func (*DBQuerier) InsertAuthorSuffix ¶
func (q *DBQuerier) InsertAuthorSuffix(ctx context.Context, params InsertAuthorSuffixParams) (InsertAuthorSuffixRow, error)
InsertAuthorSuffix implements Querier.InsertAuthorSuffix.
func (*DBQuerier) InsertAuthorSuffixBatch ¶
func (q *DBQuerier) InsertAuthorSuffixBatch(batch genericBatch, params InsertAuthorSuffixParams)
InsertAuthorSuffixBatch implements Querier.InsertAuthorSuffixBatch.
func (*DBQuerier) InsertAuthorSuffixScan ¶
func (q *DBQuerier) InsertAuthorSuffixScan(results pgx.BatchResults) (InsertAuthorSuffixRow, error)
InsertAuthorSuffixScan implements Querier.InsertAuthorSuffixScan.
func (*DBQuerier) StringAggFirstName ¶
StringAggFirstName implements Querier.StringAggFirstName.
func (*DBQuerier) StringAggFirstNameBatch ¶
StringAggFirstNameBatch implements Querier.StringAggFirstNameBatch.
func (*DBQuerier) StringAggFirstNameScan ¶
StringAggFirstNameScan implements Querier.StringAggFirstNameScan.
type FindAuthorByIDRow ¶
type FindAuthorNamesRow ¶
type FindAuthorsRow ¶
type InsertAuthorSuffixRow ¶
type Querier ¶
type Querier interface { // FindAuthorById finds one (or zero) authors by ID. FindAuthorByID(ctx context.Context, authorID int32) (FindAuthorByIDRow, error) // FindAuthorByIDBatch enqueues a FindAuthorByID query into batch to be executed // later by the batch. FindAuthorByIDBatch(batch genericBatch, authorID int32) // FindAuthorByIDScan scans the result of an executed FindAuthorByIDBatch query. FindAuthorByIDScan(results pgx.BatchResults) (FindAuthorByIDRow, error) // FindAuthors finds authors by first name. FindAuthors(ctx context.Context, firstName string) ([]FindAuthorsRow, error) // FindAuthorsBatch enqueues a FindAuthors query into batch to be executed // later by the batch. FindAuthorsBatch(batch genericBatch, firstName string) // FindAuthorsScan scans the result of an executed FindAuthorsBatch query. FindAuthorsScan(results pgx.BatchResults) ([]FindAuthorsRow, error) // FindAuthorNames finds one (or zero) authors by ID. FindAuthorNames(ctx context.Context, authorID int32) ([]FindAuthorNamesRow, error) // FindAuthorNamesBatch enqueues a FindAuthorNames query into batch to be executed // later by the batch. FindAuthorNamesBatch(batch genericBatch, authorID int32) // FindAuthorNamesScan scans the result of an executed FindAuthorNamesBatch query. FindAuthorNamesScan(results pgx.BatchResults) ([]FindAuthorNamesRow, error) // FindFirstNames finds one (or zero) authors by ID. FindFirstNames(ctx context.Context, authorID int32) ([]*string, error) // FindFirstNamesBatch enqueues a FindFirstNames query into batch to be executed // later by the batch. FindFirstNamesBatch(batch genericBatch, authorID int32) // FindFirstNamesScan scans the result of an executed FindFirstNamesBatch query. FindFirstNamesScan(results pgx.BatchResults) ([]*string, error) // DeleteAuthors deletes authors with a first name of "joe". DeleteAuthors(ctx context.Context) (pgconn.CommandTag, error) // DeleteAuthorsBatch enqueues a DeleteAuthors query into batch to be executed // later by the batch. DeleteAuthorsBatch(batch genericBatch) // DeleteAuthorsScan scans the result of an executed DeleteAuthorsBatch query. DeleteAuthorsScan(results pgx.BatchResults) (pgconn.CommandTag, error) // DeleteAuthorsByFirstName deletes authors by first name. DeleteAuthorsByFirstName(ctx context.Context, firstName string) (pgconn.CommandTag, error) // DeleteAuthorsByFirstNameBatch enqueues a DeleteAuthorsByFirstName query into batch to be executed // later by the batch. DeleteAuthorsByFirstNameBatch(batch genericBatch, firstName string) // DeleteAuthorsByFirstNameScan scans the result of an executed DeleteAuthorsByFirstNameBatch query. DeleteAuthorsByFirstNameScan(results pgx.BatchResults) (pgconn.CommandTag, error) // DeleteAuthorsByFullName deletes authors by the full name. DeleteAuthorsByFullName(ctx context.Context, params DeleteAuthorsByFullNameParams) (pgconn.CommandTag, error) // DeleteAuthorsByFullNameBatch enqueues a DeleteAuthorsByFullName query into batch to be executed // later by the batch. DeleteAuthorsByFullNameBatch(batch genericBatch, params DeleteAuthorsByFullNameParams) // DeleteAuthorsByFullNameScan scans the result of an executed DeleteAuthorsByFullNameBatch query. DeleteAuthorsByFullNameScan(results pgx.BatchResults) (pgconn.CommandTag, error) // InsertAuthor inserts an author by name and returns the ID. InsertAuthor(ctx context.Context, firstName string, lastName string) (int32, error) // InsertAuthorBatch enqueues a InsertAuthor query into batch to be executed // later by the batch. InsertAuthorBatch(batch genericBatch, firstName string, lastName string) // InsertAuthorScan scans the result of an executed InsertAuthorBatch query. InsertAuthorScan(results pgx.BatchResults) (int32, error) // InsertAuthorSuffix inserts an author by name and suffix and returns the // entire row. InsertAuthorSuffix(ctx context.Context, params InsertAuthorSuffixParams) (InsertAuthorSuffixRow, error) // InsertAuthorSuffixBatch enqueues a InsertAuthorSuffix query into batch to be executed // later by the batch. InsertAuthorSuffixBatch(batch genericBatch, params InsertAuthorSuffixParams) // InsertAuthorSuffixScan scans the result of an executed InsertAuthorSuffixBatch query. InsertAuthorSuffixScan(results pgx.BatchResults) (InsertAuthorSuffixRow, error) StringAggFirstName(ctx context.Context, authorID int32) (*string, error) // StringAggFirstNameBatch enqueues a StringAggFirstName query into batch to be executed // later by the batch. StringAggFirstNameBatch(batch genericBatch, authorID int32) // StringAggFirstNameScan scans the result of an executed StringAggFirstNameBatch query. StringAggFirstNameScan(results pgx.BatchResults) (*string, error) ArrayAggFirstName(ctx context.Context, authorID int32) ([]string, error) // ArrayAggFirstNameBatch enqueues a ArrayAggFirstName query into batch to be executed // later by the batch. ArrayAggFirstNameBatch(batch genericBatch, authorID int32) // ArrayAggFirstNameScan scans the result of an executed ArrayAggFirstNameBatch query. ArrayAggFirstNameScan(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 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 }