add read sensor query
This commit is contained in:
parent
23ec2d5789
commit
f6d94bff1a
@ -50,10 +50,21 @@ func (p *pgxRepo) UpdateSensor(s Sensor) error {
|
||||
return err
|
||||
}
|
||||
|
||||
const readSensorBySensorID = ``
|
||||
const readSensorBySensorID = `select sensor_id, sensor_type, sampling_interval, threshold_above, threshold_below from sensors where sensor_id = $1`
|
||||
|
||||
func (p *pgxRepo) ReadSensor(sensorID string) (Sensor, error) {
|
||||
panic("unimplemented")
|
||||
var s Sensor
|
||||
err := p.QueryRow(context.Background(), readSensorBySensorID, sensorID).Scan(
|
||||
&s.SensorID,
|
||||
&s.SensorType,
|
||||
&s.SamplingInterval,
|
||||
&s.ThresholdAbove,
|
||||
&s.ThresholdBelow,
|
||||
)
|
||||
if err != nil {
|
||||
return Sensor{}, ErrSensorNotFound
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
|
||||
const readSensorValuesBySensorID = ``
|
||||
|
||||
Loading…
Reference in New Issue
Block a user