Documentation ¶
Index ¶
- func PrepareAllQueries(ctx context.Context, p preparer) error
- type CompositeUserOneTwoColsRow
- type CompositeUserRow
- type DBQuerier
- func (q *DBQuerier) CompositeUser(ctx context.Context) ([]CompositeUserRow, error)
- func (q *DBQuerier) CompositeUserBatch(batch genericBatch)
- func (q *DBQuerier) CompositeUserMany(ctx context.Context) ([]User, error)
- func (q *DBQuerier) CompositeUserManyBatch(batch genericBatch)
- func (q *DBQuerier) CompositeUserManyScan(results pgx.BatchResults) ([]User, error)
- func (q *DBQuerier) CompositeUserOne(ctx context.Context) (User, error)
- func (q *DBQuerier) CompositeUserOneBatch(batch genericBatch)
- func (q *DBQuerier) CompositeUserOneScan(results pgx.BatchResults) (User, error)
- func (q *DBQuerier) CompositeUserOneTwoCols(ctx context.Context) (CompositeUserOneTwoColsRow, error)
- func (q *DBQuerier) CompositeUserOneTwoColsBatch(batch genericBatch)
- func (q *DBQuerier) CompositeUserOneTwoColsScan(results pgx.BatchResults) (CompositeUserOneTwoColsRow, error)
- func (q *DBQuerier) CompositeUserScan(results pgx.BatchResults) ([]CompositeUserRow, error)
- func (q *DBQuerier) FindDevicesByUser(ctx context.Context, id int) ([]FindDevicesByUserRow, error)
- func (q *DBQuerier) FindDevicesByUserBatch(batch genericBatch, id int)
- func (q *DBQuerier) FindDevicesByUserScan(results pgx.BatchResults) ([]FindDevicesByUserRow, error)
- func (q *DBQuerier) InsertDevice(ctx context.Context, mac pgtype.Macaddr, owner int) (pgconn.CommandTag, error)
- func (q *DBQuerier) InsertDeviceBatch(batch genericBatch, mac pgtype.Macaddr, owner int)
- func (q *DBQuerier) InsertDeviceScan(results pgx.BatchResults) (pgconn.CommandTag, error)
- func (q *DBQuerier) InsertUser(ctx context.Context, userID int, name string) (pgconn.CommandTag, error)
- func (q *DBQuerier) InsertUserBatch(batch genericBatch, userID int, name string)
- func (q *DBQuerier) InsertUserScan(results pgx.BatchResults) (pgconn.CommandTag, error)
- func (q *DBQuerier) WithTx(tx pgx.Tx) (*DBQuerier, error)
- type DeviceType
- type FindDevicesByUserRow
- type Querier
- type QuerierConfig
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrepareAllQueries ¶
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 CompositeUserRow ¶
type CompositeUserRow struct { Mac pgtype.Macaddr `json:"mac"` Type DeviceType `json:"type"` User User `json:"user"` }
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) CompositeUser ¶
func (q *DBQuerier) CompositeUser(ctx context.Context) ([]CompositeUserRow, error)
CompositeUser implements Querier.CompositeUser.
func (*DBQuerier) CompositeUserBatch ¶
func (q *DBQuerier) CompositeUserBatch(batch genericBatch)
CompositeUserBatch implements Querier.CompositeUserBatch.
func (*DBQuerier) CompositeUserMany ¶
CompositeUserMany implements Querier.CompositeUserMany.
func (*DBQuerier) CompositeUserManyBatch ¶
func (q *DBQuerier) CompositeUserManyBatch(batch genericBatch)
CompositeUserManyBatch implements Querier.CompositeUserManyBatch.
func (*DBQuerier) CompositeUserManyScan ¶
CompositeUserManyScan implements Querier.CompositeUserManyScan.
func (*DBQuerier) CompositeUserOne ¶
CompositeUserOne implements Querier.CompositeUserOne.
func (*DBQuerier) CompositeUserOneBatch ¶
func (q *DBQuerier) CompositeUserOneBatch(batch genericBatch)
CompositeUserOneBatch implements Querier.CompositeUserOneBatch.
func (*DBQuerier) CompositeUserOneScan ¶
CompositeUserOneScan implements Querier.CompositeUserOneScan.
func (*DBQuerier) CompositeUserOneTwoCols ¶
func (q *DBQuerier) CompositeUserOneTwoCols(ctx context.Context) (CompositeUserOneTwoColsRow, error)
CompositeUserOneTwoCols implements Querier.CompositeUserOneTwoCols.
func (*DBQuerier) CompositeUserOneTwoColsBatch ¶
func (q *DBQuerier) CompositeUserOneTwoColsBatch(batch genericBatch)
CompositeUserOneTwoColsBatch implements Querier.CompositeUserOneTwoColsBatch.
func (*DBQuerier) CompositeUserOneTwoColsScan ¶
func (q *DBQuerier) CompositeUserOneTwoColsScan(results pgx.BatchResults) (CompositeUserOneTwoColsRow, error)
CompositeUserOneTwoColsScan implements Querier.CompositeUserOneTwoColsScan.
func (*DBQuerier) CompositeUserScan ¶
func (q *DBQuerier) CompositeUserScan(results pgx.BatchResults) ([]CompositeUserRow, error)
CompositeUserScan implements Querier.CompositeUserScan.
func (*DBQuerier) FindDevicesByUser ¶
FindDevicesByUser implements Querier.FindDevicesByUser.
func (*DBQuerier) FindDevicesByUserBatch ¶
FindDevicesByUserBatch implements Querier.FindDevicesByUserBatch.
func (*DBQuerier) FindDevicesByUserScan ¶
func (q *DBQuerier) FindDevicesByUserScan(results pgx.BatchResults) ([]FindDevicesByUserRow, error)
FindDevicesByUserScan implements Querier.FindDevicesByUserScan.
func (*DBQuerier) InsertDevice ¶
func (q *DBQuerier) InsertDevice(ctx context.Context, mac pgtype.Macaddr, owner int) (pgconn.CommandTag, error)
InsertDevice implements Querier.InsertDevice.
func (*DBQuerier) InsertDeviceBatch ¶
InsertDeviceBatch implements Querier.InsertDeviceBatch.
func (*DBQuerier) InsertDeviceScan ¶
func (q *DBQuerier) InsertDeviceScan(results pgx.BatchResults) (pgconn.CommandTag, error)
InsertDeviceScan implements Querier.InsertDeviceScan.
func (*DBQuerier) InsertUser ¶
func (q *DBQuerier) InsertUser(ctx context.Context, userID int, name string) (pgconn.CommandTag, error)
InsertUser implements Querier.InsertUser.
func (*DBQuerier) InsertUserBatch ¶
InsertUserBatch implements Querier.InsertUserBatch.
func (*DBQuerier) InsertUserScan ¶
func (q *DBQuerier) InsertUserScan(results pgx.BatchResults) (pgconn.CommandTag, error)
InsertUserScan implements Querier.InsertUserScan.
type DeviceType ¶
type DeviceType string
DeviceType represents the Postgres enum "device_type".
const ( DeviceTypeUndefined DeviceType = "undefined" DeviceTypePhone DeviceType = "phone" DeviceTypeLaptop DeviceType = "laptop" DeviceTypeIpad DeviceType = "ipad" DeviceTypeDesktop DeviceType = "desktop" DeviceTypeIot DeviceType = "iot" )
func (DeviceType) String ¶
func (d DeviceType) String() string
type FindDevicesByUserRow ¶
type FindDevicesByUserRow struct { ID int `json:"id"` Name string `json:"name"` MacAddrs pgtype.MacaddrArray `json:"mac_addrs"` }
type Querier ¶
type Querier interface { FindDevicesByUser(ctx context.Context, id int) ([]FindDevicesByUserRow, error) // FindDevicesByUserBatch enqueues a FindDevicesByUser query into batch to be executed // later by the batch. FindDevicesByUserBatch(batch genericBatch, id int) // FindDevicesByUserScan scans the result of an executed FindDevicesByUserBatch query. FindDevicesByUserScan(results pgx.BatchResults) ([]FindDevicesByUserRow, error) CompositeUser(ctx context.Context) ([]CompositeUserRow, error) // CompositeUserBatch enqueues a CompositeUser query into batch to be executed // later by the batch. CompositeUserBatch(batch genericBatch) // CompositeUserScan scans the result of an executed CompositeUserBatch query. CompositeUserScan(results pgx.BatchResults) ([]CompositeUserRow, error) CompositeUserOne(ctx context.Context) (User, error) // CompositeUserOneBatch enqueues a CompositeUserOne query into batch to be executed // later by the batch. CompositeUserOneBatch(batch genericBatch) // CompositeUserOneScan scans the result of an executed CompositeUserOneBatch query. CompositeUserOneScan(results pgx.BatchResults) (User, error) CompositeUserOneTwoCols(ctx context.Context) (CompositeUserOneTwoColsRow, error) // CompositeUserOneTwoColsBatch enqueues a CompositeUserOneTwoCols query into batch to be executed // later by the batch. CompositeUserOneTwoColsBatch(batch genericBatch) // CompositeUserOneTwoColsScan scans the result of an executed CompositeUserOneTwoColsBatch query. CompositeUserOneTwoColsScan(results pgx.BatchResults) (CompositeUserOneTwoColsRow, error) CompositeUserMany(ctx context.Context) ([]User, error) // CompositeUserManyBatch enqueues a CompositeUserMany query into batch to be executed // later by the batch. CompositeUserManyBatch(batch genericBatch) // CompositeUserManyScan scans the result of an executed CompositeUserManyBatch query. CompositeUserManyScan(results pgx.BatchResults) ([]User, error) InsertUser(ctx context.Context, userID int, name string) (pgconn.CommandTag, error) // InsertUserBatch enqueues a InsertUser query into batch to be executed // later by the batch. InsertUserBatch(batch genericBatch, userID int, name string) // InsertUserScan scans the result of an executed InsertUserBatch query. InsertUserScan(results pgx.BatchResults) (pgconn.CommandTag, error) InsertDevice(ctx context.Context, mac pgtype.Macaddr, owner int) (pgconn.CommandTag, error) // InsertDeviceBatch enqueues a InsertDevice query into batch to be executed // later by the batch. InsertDeviceBatch(batch genericBatch, mac pgtype.Macaddr, owner int) // InsertDeviceScan scans the result of an executed InsertDeviceBatch query. InsertDeviceScan(results pgx.BatchResults) (pgconn.CommandTag, 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 }