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 CreateReadingParams
- type CreateSensorParams
- type DBTX
- type GetSensorReadingStatsParams
- type GetSensorReadingStatsRow
- type ListReadingBySensorIdParams
- type ListReadingFilterBySensorIdRecordedAtFlaggedParams
- type ListReadingFilterBySensorIdRecordedAtFlaggedRow
- type ListSensorFilterByLabelKindActiveParams
- type ListSensorFilterByLabelKindActiveRow
- type ListSensorsWithLatestReadingParams
- type ListSensorsWithLatestReadingRow
- type Queries
- func (q *Queries) CreateReading(ctx context.Context, arg CreateReadingParams) (int64, error)
- func (q *Queries) CreateSensor(ctx context.Context, arg CreateSensorParams) (int32, error)
- func (q *Queries) DeleteReading(ctx context.Context, id int64) error
- func (q *Queries) DeleteSensor(ctx context.Context, id int32) error
- func (q *Queries) GetReadingByID(ctx context.Context, id int64) (*Reading, 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) GetSensorReadingStats(ctx context.Context, arg internal.GetSensorReadingStatsParams) (internal.GetSensorReadingStatsRow, error)
- func (q *Queries) ListReadingBySensorId(ctx context.Context, arg ListReadingBySensorIdParams) ([]*Reading, error)
- func (q *Queries) ListReadingFilterBySensorIdRecordedAtFlagged(ctx context.Context, arg ListReadingFilterBySensorIdRecordedAtFlaggedParams) ([]*Reading, int64, error)
- func (q *Queries) ListSensorFilterByLabelKindActive(ctx context.Context, arg ListSensorFilterByLabelKindActiveParams) ([]*Sensor, 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) UpdateReading(ctx context.Context, arg UpdateReadingParams) (*Reading, error)
- func (q *Queries) UpdateSensor(ctx context.Context, arg UpdateSensorParams) (*Sensor, error)
- func (q *Queries) WithTx(tx *sql.Tx) *Queries
- type Reading
- type Sensor
- type UpdateReadingParams
- type UpdateSensorParams
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 CreateReadingParams ¶
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 GetSensorReadingStatsParams ¶
type GetSensorReadingStatsParams = internal.GetSensorReadingStatsParams
type GetSensorReadingStatsRow ¶
type GetSensorReadingStatsRow = internal.GetSensorReadingStatsRow
type ListReadingBySensorIdParams ¶ added in v0.0.4
type ListReadingFilterBySensorIdRecordedAtFlaggedRow ¶ added in v0.0.5
type ListReadingFilterBySensorIdRecordedAtFlaggedRow = internal.ListReadingFilterBySensorIdRecordedAtFlaggedRow
type ListSensorFilterByLabelKindActiveRow ¶ added in v0.0.5
type ListSensorFilterByLabelKindActiveRow = internal.ListSensorFilterByLabelKindActiveRow
type ListSensorsWithLatestReadingParams ¶
type ListSensorsWithLatestReadingParams = internal.ListSensorsWithLatestReadingParams
type ListSensorsWithLatestReadingRow ¶
type ListSensorsWithLatestReadingRow = internal.ListSensorsWithLatestReadingRow
type Queries ¶
func (*Queries) CreateReading ¶
func (*Queries) CreateSensor ¶
func (*Queries) DeleteReading ¶
func (*Queries) GetReadingByID ¶
func (*Queries) GetSensorByCode ¶
func (*Queries) GetSensorByID ¶
func (*Queries) GetSensorReadingStats ¶
func (q *Queries) GetSensorReadingStats(ctx context.Context, arg internal.GetSensorReadingStatsParams) (internal.GetSensorReadingStatsRow, error)
func (*Queries) ListReadingBySensorId ¶
func (*Queries) ListReadingFilterBySensorIdRecordedAtFlagged ¶
func (*Queries) ListSensorFilterByLabelKindActive ¶
func (*Queries) ListSensorsWithLatestReading ¶
func (q *Queries) ListSensorsWithLatestReading(ctx context.Context, arg internal.ListSensorsWithLatestReadingParams) ([]internal.ListSensorsWithLatestReadingRow, error)
func (*Queries) PruneReadingsOlderThan ¶
func (*Queries) UpdateReading ¶
func (*Queries) UpdateSensor ¶
type Reading ¶
type Reading 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 ReadingFromSQL ¶
func (*Reading) ReadingToSQL ¶
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 UpdateReadingParams ¶
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.