Help us shape the future of Go! Take the 2026 Go Developer Survey

internal

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateReadingParams

type CreateReadingParams struct {
	SensorID   int64     `json:"sensor_id"`
	Value      float64   `json:"value"`
	Quality    int64     `json:"quality"`
	Flagged    int64     `json:"flagged"`
	RecordedAt time.Time `json:"recorded_at"`
	CreatedAt  time.Time `json:"created_at"`
}

type CreateSensorParams

type CreateSensorParams struct {
	Code         string    `json:"code"`
	Label        string    `json:"label"`
	Kind         string    `json:"kind"`
	Unit         string    `json:"unit"`
	Location     *string   `json:"location"`
	Active       int64     `json:"active"`
	Firmware     string    `json:"firmware"`
	SampleRateMs int64     `json:"sample_rate_ms"`
	InstalledAt  time.Time `json:"installed_at"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type GetSensorReadingStatsParams

type GetSensorReadingStatsParams struct {
	SensorID int64     `json:"sensor_id"`
	FromTs   time.Time `json:"from_ts"`
	ToTs     time.Time `json:"to_ts"`
}

type GetSensorReadingStatsRow

type GetSensorReadingStatsRow struct {
	ReadingCount int64       `json:"reading_count"`
	AvgValue     *float64    `json:"avg_value"`
	MinValue     interface{} `json:"min_value"`
	MaxValue     interface{} `json:"max_value"`
}

type ListReadingBySensorIdParams added in v0.0.4

type ListReadingBySensorIdParams struct {
	SensorID int64 `json:"sensor_id"`
	Offset   int64 `json:"offset"`
	Limit    int64 `json:"limit"`
}

type ListReadingFilterBySensorIdRecordedAtFlaggedParams

type ListReadingFilterBySensorIdRecordedAtFlaggedParams struct {
	SensorID int64 `json:"sensor_id"`
	Flagged  int64 `json:"flagged"`
	Offset   int64 `json:"offset"`
	Limit    int64 `json:"limit"`
}

type ListReadingFilterBySensorIdRecordedAtFlaggedRow added in v0.0.5

type ListReadingFilterBySensorIdRecordedAtFlaggedRow struct {
	ID         int64     `json:"id"`
	SensorID   int64     `json:"sensor_id"`
	Value      float64   `json:"value"`
	Quality    int64     `json:"quality"`
	Flagged    int64     `json:"flagged"`
	RecordedAt time.Time `json:"recorded_at"`
	CreatedAt  time.Time `json:"created_at"`
	TotalSize  int64     `json:"total_size"`
}

type ListSensorFilterByLabelKindActiveParams

type ListSensorFilterByLabelKindActiveParams struct {
	Label  string `json:"label"`
	Kind   string `json:"kind"`
	Active int64  `json:"active"`
	Offset int64  `json:"offset"`
	Limit  int64  `json:"limit"`
}

type ListSensorFilterByLabelKindActiveRow added in v0.0.5

type ListSensorFilterByLabelKindActiveRow struct {
	ID           int64     `json:"id"`
	Code         string    `json:"code"`
	Label        string    `json:"label"`
	Kind         string    `json:"kind"`
	Unit         string    `json:"unit"`
	Location     *string   `json:"location"`
	Active       int64     `json:"active"`
	Firmware     string    `json:"firmware"`
	SampleRateMs int64     `json:"sample_rate_ms"`
	InstalledAt  time.Time `json:"installed_at"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
	TotalSize    int64     `json:"total_size"`
}

type ListSensorsWithLatestReadingParams

type ListSensorsWithLatestReadingParams struct {
	Offset int64 `json:"offset"`
	Limit  int64 `json:"limit"`
}

type ListSensorsWithLatestReadingRow

type ListSensorsWithLatestReadingRow struct {
	Sensor           Sensor     `json:"sensor"`
	LatestValue      *float64   `json:"latest_value"`
	LatestRecordedAt *time.Time `json:"latest_recorded_at"`
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) CreateReading

func (q *Queries) CreateReading(ctx context.Context, arg CreateReadingParams) (int64, error)

Code generated by entlite. DO NOT EDIT. SQLC compatible query definitions Reading CRUD operations

func (*Queries) CreateSensor

func (q *Queries) CreateSensor(ctx context.Context, arg CreateSensorParams) (int64, error)

Sensor CRUD operations

func (*Queries) DB

func (q *Queries) DB() DBTX

DB returns the handle this Queries was constructed with.

func (*Queries) DeleteReading

func (q *Queries) DeleteReading(ctx context.Context, id int64) error

func (*Queries) DeleteSensor

func (q *Queries) DeleteSensor(ctx context.Context, id int64) error

func (*Queries) GetReadingByID

func (q *Queries) GetReadingByID(ctx context.Context, id int64) (Reading, error)

func (*Queries) GetSensorByCode

func (q *Queries) GetSensorByCode(ctx context.Context, code string) (Sensor, error)

Look up a sensor by its hardware code

func (*Queries) GetSensorByID

func (q *Queries) GetSensorByID(ctx context.Context, id int64) (Sensor, error)

func (*Queries) GetSensorReadingStats

func (q *Queries) GetSensorReadingStats(ctx context.Context, arg GetSensorReadingStatsParams) (GetSensorReadingStatsRow, error)

Hand-written queries the DSL cannot express. entlite never writes this file. The tables are defined in the generated schema.sql. Aggregate value statistics for a single sensor over a time window. >= / <= instead of BETWEEN: sqlc cannot infer a DATETIME type inside BETWEEN and drops the bounds from the params struct.

func (*Queries) ListReadingBySensorId

func (q *Queries) ListReadingBySensorId(ctx context.Context, arg ListReadingBySensorIdParams) ([]Reading, error)

func (*Queries) ListSensorsWithLatestReading

func (q *Queries) ListSensorsWithLatestReading(ctx context.Context, arg ListSensorsWithLatestReadingParams) ([]ListSensorsWithLatestReadingRow, error)

Every active sensor with its most recent reading. LEFT JOIN, so a sensor that never reported comes back with NULL latest values. sqlc.embed(s) maps the joined columns back to the Sensor struct.

func (*Queries) PruneReadingsOlderThan

func (q *Queries) PruneReadingsOlderThan(ctx context.Context, cutoff time.Time) (int64, error)

Drops readings older than a cutoff.

func (*Queries) UpdateReading

func (q *Queries) UpdateReading(ctx context.Context, arg UpdateReadingParams) (Reading, error)

func (*Queries) UpdateSensor

func (q *Queries) UpdateSensor(ctx context.Context, arg UpdateSensorParams) (Sensor, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type Reading

type Reading struct {
	ID         int64     `json:"id"`
	SensorID   int64     `json:"sensor_id"`
	Value      float64   `json:"value"`
	Quality    int64     `json:"quality"`
	Flagged    int64     `json:"flagged"`
	RecordedAt time.Time `json:"recorded_at"`
	CreatedAt  time.Time `json:"created_at"`
}

type Sensor

type Sensor struct {
	ID           int64     `json:"id"`
	Code         string    `json:"code"`
	Label        string    `json:"label"`
	Kind         string    `json:"kind"`
	Unit         string    `json:"unit"`
	Location     *string   `json:"location"`
	Active       int64     `json:"active"`
	Firmware     string    `json:"firmware"`
	SampleRateMs int64     `json:"sample_rate_ms"`
	InstalledAt  time.Time `json:"installed_at"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

type UpdateReadingParams

type UpdateReadingParams struct {
	SensorID   int64     `json:"sensor_id"`
	Value      float64   `json:"value"`
	Quality    int64     `json:"quality"`
	Flagged    *int64    `json:"flagged"`
	RecordedAt time.Time `json:"recorded_at"`
	ID         int64     `json:"ID"`
}

type UpdateSensorParams

type UpdateSensorParams struct {
	Code         string    `json:"code"`
	Label        string    `json:"label"`
	Kind         string    `json:"kind"`
	Unit         string    `json:"unit"`
	Location     *string   `json:"location"`
	Active       *int64    `json:"active"`
	Firmware     *string   `json:"firmware"`
	SampleRateMs *int64    `json:"sample_rate_ms"`
	UpdatedAt    time.Time `json:"updated_at"`
	ID           int64     `json:"ID"`
}

Jump to

Keyboard shortcuts

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