enums

package
v0.0.0-...-3259c9a Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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.

func (*DBQuerier) EnumInsideComposite

func (q *DBQuerier) EnumInsideComposite(ctx context.Context) (Device, error)

EnumInsideComposite implements Querier.EnumInsideComposite.

func (*DBQuerier) FindAllDevices

func (q *DBQuerier) FindAllDevices(ctx context.Context) ([]FindAllDevicesRow, error)

FindAllDevices implements Querier.FindAllDevices.

func (*DBQuerier) FindManyDeviceArray

func (q *DBQuerier) FindManyDeviceArray(ctx context.Context) ([][]DeviceType, error)

FindManyDeviceArray implements Querier.FindManyDeviceArray.

func (*DBQuerier) FindManyDeviceArrayWithNum

func (q *DBQuerier) FindManyDeviceArrayWithNum(ctx context.Context) ([]FindManyDeviceArrayWithNumRow, error)

FindManyDeviceArrayWithNum implements Querier.FindManyDeviceArrayWithNum.

func (*DBQuerier) FindOneDeviceArray

func (q *DBQuerier) FindOneDeviceArray(ctx context.Context) ([]DeviceType, error)

FindOneDeviceArray implements Querier.FindOneDeviceArray.

func (*DBQuerier) InsertDevice

func (q *DBQuerier) InsertDevice(ctx context.Context, mac pgtype.Macaddr, typePg DeviceType) (pgconn.CommandTag, error)

InsertDevice implements Querier.InsertDevice.

type Device

type Device struct {
	Mac  pgtype.Macaddr `json:"mac"`
	Type DeviceType     `json:"type"`
}

Device represents the Postgres composite type "device".

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 FindAllDevicesRow

type FindAllDevicesRow struct {
	Mac  pgtype.Macaddr `json:"mac"`
	Type DeviceType     `json:"type"`
}

type FindManyDeviceArrayWithNumRow

type FindManyDeviceArrayWithNumRow struct {
	Num         *int32       `json:"num"`
	DeviceTypes []DeviceType `json:"device_types"`
}

type Querier

type Querier interface {
	FindAllDevices(ctx context.Context) ([]FindAllDevicesRow, error)

	InsertDevice(ctx context.Context, mac pgtype.Macaddr, typePg DeviceType) (pgconn.CommandTag, error)

	// Select an array of all device_type enum values.
	FindOneDeviceArray(ctx context.Context) ([]DeviceType, error)

	// Select many rows of device_type enum values.
	FindManyDeviceArray(ctx context.Context) ([][]DeviceType, error)

	// Select many rows of device_type enum values with multiple output columns.
	FindManyDeviceArrayWithNum(ctx context.Context) ([]FindManyDeviceArrayWithNumRow, error)

	// Regression test for https://github.com/jschaf/pggen/issues/23.
	EnumInsideComposite(ctx context.Context) (Device, error)
}

Querier is a typesafe Go interface backed by SQL queries.

Jump to

Keyboard shortcuts

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