Documentation ¶
Index ¶
- type Database
- type Postgres
- func (postgres *Postgres) Close() error
- func (postgres *Postgres) DeleteDevices(ctx context.Context, deviceIDs ...string) error
- func (postgres *Postgres) DeleteSensors(ctx context.Context, sensorIDs ...string) error
- func (postgres *Postgres) InsertDevices(ctx context.Context, devices ...*types.Device) error
- func (postgres *Postgres) InsertMeasuredValues(ctx context.Context, measuredValues ...*types.MeasuredValue) error
- func (postgres *Postgres) InsertOrUpdateDevices(ctx context.Context, devices ...*types.Device) error
- func (postgres *Postgres) InsertOrUpdateMeasuredValues(ctx context.Context, measuredValues ...*types.MeasuredValue) error
- func (postgres *Postgres) InsertOrUpdateSensors(ctx context.Context, sensors ...*types.Sensor) error
- func (postgres *Postgres) InsertSensors(ctx context.Context, sensors ...*types.Sensor) error
- func (postgres *Postgres) Migrate(ctx context.Context) error
- func (postgres *Postgres) SelectDevice(ctx context.Context, id string) (*types.Device, error)
- func (postgres *Postgres) SelectDevices(ctx context.Context) ([]*types.Device, error)
- func (postgres *Postgres) SelectHumidities(ctx context.Context) ([]*types.MeasuredValue, error)
- func (postgres *Postgres) SelectHumidity(ctx context.Context, id string) (*types.MeasuredValue, error)
- func (postgres *Postgres) SelectPressure(ctx context.Context, id string) (*types.MeasuredValue, error)
- func (postgres *Postgres) SelectPressures(ctx context.Context) ([]*types.MeasuredValue, error)
- func (postgres *Postgres) SelectSensor(ctx context.Context, id string) (*types.Sensor, error)
- func (postgres *Postgres) SelectSensors(ctx context.Context) ([]*types.Sensor, error)
- func (postgres *Postgres) SelectTemperature(ctx context.Context, id string) (*types.MeasuredValue, error)
- func (postgres *Postgres) SelectTemperatures(ctx context.Context) ([]*types.MeasuredValue, error)
- func (postgres *Postgres) UpdateDevices(ctx context.Context, devices ...*types.Device) error
- func (postgres *Postgres) UpdateSensors(ctx context.Context, sensors ...*types.Sensor) error
- type SQLite
- func (sqlite *SQLite) Close() error
- func (sqlite *SQLite) DeleteDevices(ctx context.Context, deviceIDs ...string) error
- func (sqlite *SQLite) DeleteSensors(ctx context.Context, sensorIDs ...string) error
- func (sqlite *SQLite) ExistDevice(ctx context.Context, deviceID string) (bool, error)
- func (sqlite *SQLite) ExistDevices(ctx context.Context, deviceIDs ...string) (map[string]bool, error)
- func (sqlite *SQLite) InsertDevices(ctx context.Context, devices ...*types.Device) error
- func (sqlite *SQLite) InsertMeasuredValues(ctx context.Context, measuredValues ...*types.MeasuredValue) error
- func (sqlite *SQLite) InsertOrUpdateDevices(ctx context.Context, devices ...*types.Device) error
- func (sqlite *SQLite) InsertOrUpdateMeasuredValues(ctx context.Context, measuredValues ...*types.MeasuredValue) error
- func (sqlite *SQLite) InsertOrUpdateSensors(ctx context.Context, sensors ...*types.Sensor) error
- func (sqlite *SQLite) InsertSensors(ctx context.Context, sensors ...*types.Sensor) error
- func (sqlite *SQLite) Migrate(ctx context.Context) error
- func (sqlite *SQLite) SelectDevice(ctx context.Context, id string) (*types.Device, error)
- func (sqlite *SQLite) SelectDevices(ctx context.Context) ([]*types.Device, error)
- func (sqlite *SQLite) SelectHumidities(ctx context.Context) ([]*types.MeasuredValue, error)
- func (sqlite *SQLite) SelectHumidity(ctx context.Context, id string) (*types.MeasuredValue, error)
- func (sqlite *SQLite) SelectPressure(ctx context.Context, id string) (*types.MeasuredValue, error)
- func (sqlite *SQLite) SelectPressures(ctx context.Context) ([]*types.MeasuredValue, error)
- func (sqlite *SQLite) SelectSensor(ctx context.Context, id string) (*types.Sensor, error)
- func (sqlite *SQLite) SelectSensors(ctx context.Context) ([]*types.Sensor, error)
- func (sqlite *SQLite) SelectTemperature(ctx context.Context, id string) (*types.MeasuredValue, error)
- func (sqlite *SQLite) SelectTemperatures(ctx context.Context) ([]*types.MeasuredValue, error)
- func (sqlite *SQLite) UpdateDevices(ctx context.Context, devices ...*types.Device) error
- func (sqlite *SQLite) UpdateSensors(ctx context.Context, sensors ...*types.Sensor) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database interface { Close() error DeleteDevices(ctx context.Context, deviceIDs ...string) error DeleteSensors(ctx context.Context, sensorIDs ...string) error InsertDevices(ctx context.Context, devices ...*types.Device) error InsertOrUpdateDevices(ctx context.Context, devices ...*types.Device) error InsertMeasuredValues(ctx context.Context, measuredValues ...*types.MeasuredValue) error InsertOrUpdateMeasuredValues(ctx context.Context, measuredValues ...*types.MeasuredValue) error InsertSensors(ctx context.Context, sensors ...*types.Sensor) error InsertOrUpdateSensors(ctx context.Context, sensors ...*types.Sensor) error Migrate(ctx context.Context) error SelectDevice(ctx context.Context, deviceID string) (*types.Device, error) SelectDevices(ctx context.Context) ([]*types.Device, error) SelectHumidity(ctx context.Context, id string) (*types.MeasuredValue, error) SelectHumidities(ctx context.Context) ([]*types.MeasuredValue, error) SelectPressure(ctx context.Context, id string) (*types.MeasuredValue, error) SelectPressures(ctx context.Context) ([]*types.MeasuredValue, error) SelectSensor(ctx context.Context, sensorID string) (*types.Sensor, error) SelectSensors(ctx context.Context) ([]*types.Sensor, error) SelectTemperature(ctx context.Context, id string) (*types.MeasuredValue, error) SelectTemperatures(ctx context.Context) ([]*types.MeasuredValue, error) UpdateDevices(ctx context.Context, devices ...*types.Device) error UpdateSensors(ctx context.Context, sensors ...*types.Sensor) error }
Database is a general interface for a database backend like postgres, oracle or sqlite
type Postgres ¶
type Postgres struct {
// contains filtered or unexported fields
}
Postgres implementation
func (*Postgres) Close ¶
Close closes the database and prevents new queries from starting. Close then waits for all queries that have started processing on the server to finish.
func (*Postgres) DeleteDevices ¶
DeleteDevices from the database
func (*Postgres) DeleteSensors ¶
DeleteSensors from the database
func (*Postgres) InsertDevices ¶
InsertDevices into the database
func (*Postgres) InsertMeasuredValues ¶
func (postgres *Postgres) InsertMeasuredValues(ctx context.Context, measuredValues ...*types.MeasuredValue) error
InsertMeasuredValues into the database
func (*Postgres) InsertOrUpdateDevices ¶ added in v0.3.0
func (*Postgres) InsertOrUpdateMeasuredValues ¶ added in v0.3.0
func (postgres *Postgres) InsertOrUpdateMeasuredValues(ctx context.Context, measuredValues ...*types.MeasuredValue) error
InsertOrUpdateMeasuredValues into the database
func (*Postgres) InsertOrUpdateSensors ¶ added in v0.3.0
func (postgres *Postgres) InsertOrUpdateSensors(ctx context.Context, sensors ...*types.Sensor) error
InsertOrUpdateSensors into the database
func (*Postgres) InsertSensors ¶
InsertSensors into the database
func (*Postgres) SelectDevice ¶
SelectDevice from database
func (*Postgres) SelectDevices ¶
SelectDevices from the database
func (*Postgres) SelectHumidities ¶
SelectHumidities returns humidities from the database
func (*Postgres) SelectHumidity ¶
func (postgres *Postgres) SelectHumidity(ctx context.Context, id string) (*types.MeasuredValue, error)
SelectHumidity returns humidity from the database
func (*Postgres) SelectPressure ¶
func (postgres *Postgres) SelectPressure(ctx context.Context, id string) (*types.MeasuredValue, error)
SelectPressure returns pressure from the database
func (*Postgres) SelectPressures ¶
SelectPressures returns pressure from the database
func (*Postgres) SelectSensor ¶
SelectSensor from database
func (*Postgres) SelectSensors ¶
SelectSensors from the database
func (*Postgres) SelectTemperature ¶
func (postgres *Postgres) SelectTemperature(ctx context.Context, id string) (*types.MeasuredValue, error)
SelectTemperature returns temperatures from the database
func (*Postgres) SelectTemperatures ¶
SelectTemperatures returns temperatures from the database
func (*Postgres) UpdateDevices ¶
UpdateDevices updates a device in the database
type SQLite ¶
type SQLite struct {
// contains filtered or unexported fields
}
SQLite implementation
func (*SQLite) Close ¶
Close closes the database and prevents new queries from starting. Close then waits for all queries that have started processing on the server to finish.
func (*SQLite) DeleteDevices ¶
DeleteDevices from the database
func (*SQLite) DeleteSensors ¶
DeleteSensors from the database
func (*SQLite) ExistDevice ¶ added in v0.3.0
func (*SQLite) ExistDevices ¶ added in v0.3.0
func (*SQLite) InsertDevices ¶
InsertDevices into the database
func (*SQLite) InsertMeasuredValues ¶
func (sqlite *SQLite) InsertMeasuredValues(ctx context.Context, measuredValues ...*types.MeasuredValue) error
InsertMeasuredValues into the database
func (*SQLite) InsertOrUpdateDevices ¶ added in v0.3.0
InsertOrUpdateDevices into the database
func (*SQLite) InsertOrUpdateMeasuredValues ¶ added in v0.3.0
func (sqlite *SQLite) InsertOrUpdateMeasuredValues(ctx context.Context, measuredValues ...*types.MeasuredValue) error
InsertOrUpdateMeasuredValues into the database
func (*SQLite) InsertOrUpdateSensors ¶ added in v0.3.0
InsertOrUpdateSensors into the database
func (*SQLite) InsertSensors ¶
InsertSensors into the database
func (*SQLite) SelectDevice ¶
SelectDevice from database
func (*SQLite) SelectDevices ¶
SelectDevices from the database
func (*SQLite) SelectHumidities ¶
SelectHumidities returns humidities from the database
func (*SQLite) SelectHumidity ¶
SelectHumidity returns humidity from the database
func (*SQLite) SelectPressure ¶
SelectPressure returns pressure from the database
func (*SQLite) SelectPressures ¶
SelectPressures returns pressure from the database
func (*SQLite) SelectSensor ¶
SelectSensor from database
func (*SQLite) SelectSensors ¶
SelectSensors from the database
func (*SQLite) SelectTemperature ¶
func (sqlite *SQLite) SelectTemperature(ctx context.Context, id string) (*types.MeasuredValue, error)
SelectTemperature returns temperatures from the database
func (*SQLite) SelectTemperatures ¶
SelectTemperatures returns temperatures from the database
func (*SQLite) UpdateDevices ¶
UpdateDevices updates a device in the database