device

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 CompositeUserOneTwoColsRow

type CompositeUserOneTwoColsRow struct {
	Num  int32 `json:"num"`
	User User  `json:"user"`
}

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.

func (*DBQuerier) CompositeUser

func (q *DBQuerier) CompositeUser(ctx context.Context) ([]CompositeUserRow, error)

CompositeUser implements Querier.CompositeUser.

func (*DBQuerier) CompositeUserMany

func (q *DBQuerier) CompositeUserMany(ctx context.Context) ([]User, error)

CompositeUserMany implements Querier.CompositeUserMany.

func (*DBQuerier) CompositeUserOne

func (q *DBQuerier) CompositeUserOne(ctx context.Context) (User, error)

CompositeUserOne implements Querier.CompositeUserOne.

func (*DBQuerier) CompositeUserOneTwoCols

func (q *DBQuerier) CompositeUserOneTwoCols(ctx context.Context) (CompositeUserOneTwoColsRow, error)

CompositeUserOneTwoCols implements Querier.CompositeUserOneTwoCols.

func (*DBQuerier) FindDevicesByUser

func (q *DBQuerier) FindDevicesByUser(ctx context.Context, id int) ([]FindDevicesByUserRow, error)

FindDevicesByUser implements Querier.FindDevicesByUser.

func (*DBQuerier) InsertDevice

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

InsertDevice implements Querier.InsertDevice.

func (*DBQuerier) InsertUser

func (q *DBQuerier) InsertUser(ctx context.Context, userID int, name string) (pgconn.CommandTag, error)

InsertUser implements Querier.InsertUser.

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)

	CompositeUser(ctx context.Context) ([]CompositeUserRow, error)

	CompositeUserOne(ctx context.Context) (User, error)

	CompositeUserOneTwoCols(ctx context.Context) (CompositeUserOneTwoColsRow, error)

	CompositeUserMany(ctx context.Context) ([]User, error)

	InsertUser(ctx context.Context, userID int, name string) (pgconn.CommandTag, error)

	InsertDevice(ctx context.Context, mac pgtype.Macaddr, owner int) (pgconn.CommandTag, error)
}

Querier is a typesafe Go interface backed by SQL queries.

type User

type User struct {
	ID   *int    `json:"id"`
	Name *string `json:"name"`
}

User represents the Postgres composite type "user".

Jump to

Keyboard shortcuts

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