nested

package
v0.0.0-...-1a642c0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareAllQueries

func PrepareAllQueries(ctx context.Context, p preparer) error

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 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) ArrayNested2

func (q *DBQuerier) ArrayNested2(ctx context.Context) ([]ProductImageType, error)

ArrayNested2 implements Querier.ArrayNested2.

func (*DBQuerier) ArrayNested2Batch

func (q *DBQuerier) ArrayNested2Batch(batch genericBatch)

ArrayNested2Batch implements Querier.ArrayNested2Batch.

func (*DBQuerier) ArrayNested2Scan

func (q *DBQuerier) ArrayNested2Scan(results pgx.BatchResults) ([]ProductImageType, error)

ArrayNested2Scan implements Querier.ArrayNested2Scan.

func (*DBQuerier) Nested3

func (q *DBQuerier) Nested3(ctx context.Context) ([]ProductImageSetType, error)

Nested3 implements Querier.Nested3.

func (*DBQuerier) Nested3Batch

func (q *DBQuerier) Nested3Batch(batch genericBatch)

Nested3Batch implements Querier.Nested3Batch.

func (*DBQuerier) Nested3Scan

func (q *DBQuerier) Nested3Scan(results pgx.BatchResults) ([]ProductImageSetType, error)

Nested3Scan implements Querier.Nested3Scan.

func (*DBQuerier) WithTx

func (q *DBQuerier) WithTx(tx pgx.Tx) (*DBQuerier, error)

WithTx creates a new DBQuerier that uses the transaction to run all queries.

type Dimensions

type Dimensions struct {
	Width  int `json:"width"`
	Height int `json:"height"`
}

Dimensions represents the Postgres composite type "dimensions".

type ProductImageSetType

type ProductImageSetType struct {
	Name      string             `json:"name"`
	OrigImage ProductImageType   `json:"orig_image"`
	Images    []ProductImageType `json:"images"`
}

ProductImageSetType represents the Postgres composite type "product_image_set_type".

type ProductImageType

type ProductImageType struct {
	Source     string     `json:"source"`
	Dimensions Dimensions `json:"dimensions"`
}

ProductImageType represents the Postgres composite type "product_image_type".

type Querier

type Querier interface {
	ArrayNested2(ctx context.Context) ([]ProductImageType, error)
	// ArrayNested2Batch enqueues a ArrayNested2 query into batch to be executed
	// later by the batch.
	ArrayNested2Batch(batch genericBatch)
	// ArrayNested2Scan scans the result of an executed ArrayNested2Batch query.
	ArrayNested2Scan(results pgx.BatchResults) ([]ProductImageType, error)

	Nested3(ctx context.Context) ([]ProductImageSetType, error)
	// Nested3Batch enqueues a Nested3 query into batch to be executed
	// later by the batch.
	Nested3Batch(batch genericBatch)
	// Nested3Scan scans the result of an executed Nested3Batch query.
	Nested3Scan(results pgx.BatchResults) ([]ProductImageSetType, 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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL