Documentation
¶
Index ¶
- func IntConvert[From, To ...](src From) To
- func IntPtrConvert[From, To ~int | ~int32 | ~int64 | ~float32 | ~float64](src *From) *To
- func NullBoolToPtr(n sql.NullBool) *bool
- func NullBytesToPtr(b []byte) *[]byte
- func NullFloat64ToPtr(n sql.NullFloat64) *float64
- func NullInt32ToPtr(n sql.NullInt32) *int32
- func NullInt64ToPtr(n sql.NullInt64) *int64
- func NullStringToPtr(n sql.NullString) *string
- func NullTimeToProto(n sql.NullTime) *timestamppb.Timestamp
- func OptionalWithFallback[T any](val *T, fallback T) T
- func ProtoToNullTime(t *timestamppb.Timestamp) sql.NullTime
- func ProtoToTime(t *timestamppb.Timestamp) time.Time
- func PtrBytesToNullString(p *[]byte) sql.NullString
- func PtrToNullBool(p *bool) sql.NullBool
- func PtrToNullBytes(b *[]byte) []byte
- func PtrToNullFloat64(p *float64) sql.NullFloat64
- func PtrToNullInt32(p *int32) sql.NullInt32
- func PtrToNullInt64(p *int64) sql.NullInt64
- func PtrToNullString(p *string) sql.NullString
- func SQLiteBoolPtrToInt64Ptr(b *bool) *int64
- func SQLiteBoolToInt(b bool) int64
- func SQLiteInt64PtrToBoolPtr(i *int64) *bool
- func SQLiteIntToBool(i int64) bool
- func TimeToProto(t time.Time) *timestamppb.Timestamp
- type CreateSensorParams
- type CreateSensorReadingParams
- type DBTX
- type GetSensorReadingStatsParams
- type GetSensorReadingStatsRow
- type ListSensorFilterByLabelKindActiveParams
- type ListSensorFilterByLabelKindActiveRow
- type ListSensorReadingBySensorIdParams
- type ListSensorReadingFilterBySensorIdRecordedAtFlaggedParams
- type ListSensorReadingFilterBySensorIdRecordedAtFlaggedRow
- type ListSensorsWithLatestReadingParams
- type ListSensorsWithLatestReadingRow
- type Queries
- func (q *Queries) CreateSensor(ctx context.Context, arg CreateSensorParams) (int32, error)
- func (q *Queries) CreateSensorReading(ctx context.Context, arg CreateSensorReadingParams) (int64, error)
- func (q *Queries) DeleteSensor(ctx context.Context, id int32) error
- func (q *Queries) DeleteSensorReading(ctx context.Context, id int64) error
- func (q *Queries) GetSensorByCode(ctx context.Context, code string) (*Sensor, error)
- func (q *Queries) GetSensorById(ctx context.Context, id int32) (*Sensor, error)
- func (q *Queries) GetSensorReadingById(ctx context.Context, id int64) (*SensorReading, error)
- func (q *Queries) GetSensorReadingStats(ctx context.Context, arg internal.GetSensorReadingStatsParams) (internal.GetSensorReadingStatsRow, error)
- func (q *Queries) ListSensorFilterByLabelKindActive(ctx context.Context, arg ListSensorFilterByLabelKindActiveParams) ([]*Sensor, int64, error)
- func (q *Queries) ListSensorReadingBySensorId(ctx context.Context, arg ListSensorReadingBySensorIdParams) ([]*SensorReading, error)
- func (q *Queries) ListSensorReadingFilterBySensorIdRecordedAtFlagged(ctx context.Context, ...) ([]*SensorReading, int64, error)
- func (q *Queries) ListSensorsWithLatestReading(ctx context.Context, arg internal.ListSensorsWithLatestReadingParams) ([]internal.ListSensorsWithLatestReadingRow, error)
- func (q *Queries) PruneReadingsOlderThan(ctx context.Context, cutoff time.Time) (int64, error)
- func (q *Queries) UpdateSensor(ctx context.Context, arg UpdateSensorParams) (*Sensor, error)
- func (q *Queries) UpdateSensorReading(ctx context.Context, arg UpdateSensorReadingParams) (*SensorReading, error)
- func (q *Queries) WithTx(tx *sql.Tx) *Queries
- type Sensor
- type SensorReading
- type UpdateSensorParams
- type UpdateSensorReadingParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IntConvert ¶
func IntPtrConvert ¶
example: IntPtrConvert[int64, int32](dbRow.Age)
func NullBoolToPtr ¶
func NullFloat64ToPtr ¶
func NullFloat64ToPtr(n sql.NullFloat64) *float64
func NullInt32ToPtr ¶
--- Nullable SQL Type Converters ---
func NullInt64ToPtr ¶
func NullStringToPtr ¶
func NullStringToPtr(n sql.NullString) *string
func NullTimeToProto ¶
func NullTimeToProto(n sql.NullTime) *timestamppb.Timestamp
--- Time Converters ---
func OptionalWithFallback ¶
func OptionalWithFallback[T any](val *T, fallback T) T
OptionalWithFallback chooses fallback if optional value is nil
func ProtoToNullTime ¶
func ProtoToNullTime(t *timestamppb.Timestamp) sql.NullTime
func ProtoToTime ¶
func ProtoToTime(t *timestamppb.Timestamp) time.Time
A nil pointer returns a zero time.Time{}
func PtrBytesToNullString ¶
func PtrBytesToNullString(p *[]byte) sql.NullString
PtrBytesToNullString converts *[]byte to sql.NullString for MySQL compatibility
func PtrToNullBool ¶
func PtrToNullBytes ¶
func PtrToNullFloat64 ¶
func PtrToNullFloat64(p *float64) sql.NullFloat64
func PtrToNullInt32 ¶
func PtrToNullInt64 ¶
func PtrToNullString ¶
func PtrToNullString(p *string) sql.NullString
func SQLiteBoolPtrToInt64Ptr ¶
SQLiteBoolPtrToInt64Ptr converts *bool to *int64 for nullable columns via sqlc.narg
func SQLiteBoolToInt ¶
func SQLiteInt64PtrToBoolPtr ¶
SQLiteInt64PtrToBoolPtr is the inverse of SQLiteBoolPtrToInt64Ptr.
func TimeToProto ¶
func TimeToProto(t time.Time) *timestamppb.Timestamp
TimeToProto converts time.Time to timestamppb.Timestamp pointer
Types ¶
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 *bool `json:"active"`
Firmware *string `json:"firmware"`
SampleRateMs *int32 `json:"sample_rate_ms"`
InstalledAt time.Time `json:"installed_at"`
}
type CreateSensorReadingParams ¶ added in v0.0.6
type GetSensorReadingStatsParams ¶
type GetSensorReadingStatsParams = internal.GetSensorReadingStatsParams
type GetSensorReadingStatsRow ¶
type GetSensorReadingStatsRow = internal.GetSensorReadingStatsRow
type ListSensorFilterByLabelKindActiveRow ¶ added in v0.0.5
type ListSensorFilterByLabelKindActiveRow = internal.ListSensorFilterByLabelKindActiveRow
type ListSensorReadingBySensorIdParams ¶ added in v0.0.6
type ListSensorReadingFilterBySensorIdRecordedAtFlaggedParams ¶ added in v0.0.6
type ListSensorReadingFilterBySensorIdRecordedAtFlaggedRow ¶ added in v0.0.6
type ListSensorReadingFilterBySensorIdRecordedAtFlaggedRow = internal.ListSensorReadingFilterBySensorIdRecordedAtFlaggedRow
type ListSensorsWithLatestReadingParams ¶
type ListSensorsWithLatestReadingParams = internal.ListSensorsWithLatestReadingParams
type ListSensorsWithLatestReadingRow ¶
type ListSensorsWithLatestReadingRow = internal.ListSensorsWithLatestReadingRow
type Queries ¶
func (*Queries) CreateSensor ¶
func (*Queries) CreateSensorReading ¶ added in v0.0.6
func (*Queries) DeleteSensorReading ¶ added in v0.0.6
func (*Queries) GetSensorByCode ¶
func (*Queries) GetSensorById ¶ added in v0.0.6
func (*Queries) GetSensorReadingById ¶ added in v0.0.6
func (*Queries) GetSensorReadingStats ¶
func (q *Queries) GetSensorReadingStats(ctx context.Context, arg internal.GetSensorReadingStatsParams) (internal.GetSensorReadingStatsRow, error)
func (*Queries) ListSensorFilterByLabelKindActive ¶
func (*Queries) ListSensorReadingBySensorId ¶ added in v0.0.6
func (q *Queries) ListSensorReadingBySensorId(ctx context.Context, arg ListSensorReadingBySensorIdParams) ([]*SensorReading, error)
func (*Queries) ListSensorReadingFilterBySensorIdRecordedAtFlagged ¶ added in v0.0.6
func (q *Queries) ListSensorReadingFilterBySensorIdRecordedAtFlagged(ctx context.Context, arg ListSensorReadingFilterBySensorIdRecordedAtFlaggedParams) ([]*SensorReading, int64, error)
func (*Queries) ListSensorsWithLatestReading ¶
func (q *Queries) ListSensorsWithLatestReading(ctx context.Context, arg internal.ListSensorsWithLatestReadingParams) ([]internal.ListSensorsWithLatestReadingRow, error)
func (*Queries) PruneReadingsOlderThan ¶
func (*Queries) UpdateSensor ¶
func (*Queries) UpdateSensorReading ¶ added in v0.0.6
func (q *Queries) UpdateSensorReading(ctx context.Context, arg UpdateSensorReadingParams) (*SensorReading, error)
type Sensor ¶
type Sensor struct {
ID int32 `json:"id"`
Code string `json:"code"`
Label string `json:"label"`
Kind string `json:"kind"`
Unit string `json:"unit"`
Location *string `json:"location"`
Active bool `json:"active"`
Firmware string `json:"firmware"`
SampleRateMs int32 `json:"sample_rate_ms"`
InstalledAt time.Time `json:"installed_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func SensorFromSQL ¶
func (*Sensor) SensorToSQL ¶
type SensorReading ¶ added in v0.0.6
type SensorReading struct {
ID int64 `json:"id"`
SensorID int32 `json:"sensor_id"`
Value float64 `json:"value"`
Quality int32 `json:"quality"`
Flagged bool `json:"flagged"`
RecordedAt time.Time `json:"recorded_at"`
CreatedAt time.Time `json:"created_at"`
}
func SensorReadingFromSQL ¶ added in v0.0.6
func SensorReadingFromSQL(db *internal.SensorReading) *SensorReading
func (*SensorReading) SensorReadingToSQL ¶ added in v0.0.6
func (m *SensorReading) SensorReadingToSQL() *internal.SensorReading
func (*SensorReading) ToProto ¶ added in v0.0.6
func (m *SensorReading) ToProto() *pb.SensorReading
ToProto converts SensorReading to proto format
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 *bool `json:"active"`
Firmware *string `json:"firmware"`
SampleRateMs *int32 `json:"sample_rate_ms"`
ID int32 `json:"id"`
}
Click to show internal directories.
Click to hide internal directories.