db

package
v0.0.0-...-9942e84 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	AddDevice(entity *device.Device) error
	GetDevice(id string) (*device.Device, error)
	DeleteDevice(id string) error
	ListDevices() ([]device.Device, error)
	ListSensors(deviceId string) ([]sensor.Sensor, error)
	AddSensor(sensor *sensor.Sensor) error
	GetSensor(deviceId, sensorId string) (*sensor.Sensor, error)
	DeleteSensor(deviceId, sensorId string) error

	ListPollingSensors() ([]sensor.Sensor, error)

	AddSensorValue(sensorValue *value.SensorValue) error
	GetSensorValuesSince(deviceId, sensorId string, timestamp time.Time) ([]value.SensorValue, error)
	GetCurrentSensorValue(deviceId, sensorId string) (*value.SensorValue, error)
	GetPreviousSensorValue(deviceId, sensorId string) (*value.SensorValue, error)

	AddCommand(command *command.Command) error
	GetCommand(deviceId, commandId string) (*command.Command, error)
	ListCommands(deviceId string) ([]command.Command, error)
	DeleteCommand(deviceId, commandId string) error

	ListRules() ([]rules.Rule, error)
	AddRule(rule *rules.Rule) error

	SeedDatabase()
}

type SqliteDevicesDatabase

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

func NewDevicesDatabase

func NewDevicesDatabase(db *gorm.DB) (*SqliteDevicesDatabase, error)

func (*SqliteDevicesDatabase) AddCommand

func (db *SqliteDevicesDatabase) AddCommand(command *command.Command) error

func (*SqliteDevicesDatabase) AddDevice

func (db *SqliteDevicesDatabase) AddDevice(device *device.Device) error

func (*SqliteDevicesDatabase) AddRule

func (database *SqliteDevicesDatabase) AddRule(rule *rules.Rule) error

func (*SqliteDevicesDatabase) AddSensor

func (db *SqliteDevicesDatabase) AddSensor(sensor *sensor.Sensor) error

func (*SqliteDevicesDatabase) AddSensorValue

func (db *SqliteDevicesDatabase) AddSensorValue(data *value.SensorValue) error

func (*SqliteDevicesDatabase) DeleteCommand

func (db *SqliteDevicesDatabase) DeleteCommand(deviceId, commandId string) error

func (*SqliteDevicesDatabase) DeleteDevice

func (db *SqliteDevicesDatabase) DeleteDevice(id string) error

func (*SqliteDevicesDatabase) DeleteSensor

func (db *SqliteDevicesDatabase) DeleteSensor(deviceId, sensorId string) error

func (*SqliteDevicesDatabase) GetCommand

func (db *SqliteDevicesDatabase) GetCommand(deviceId, commandId string) (*command.Command, error)

func (*SqliteDevicesDatabase) GetCurrentSensorValue

func (db *SqliteDevicesDatabase) GetCurrentSensorValue(deviceId, sensorId string) (*value.SensorValue, error)

func (*SqliteDevicesDatabase) GetDevice

func (db *SqliteDevicesDatabase) GetDevice(id string) (*device.Device, error)

func (*SqliteDevicesDatabase) GetPreviousSensorValue

func (db *SqliteDevicesDatabase) GetPreviousSensorValue(deviceId, sensorId string) (*value.SensorValue, error)

func (*SqliteDevicesDatabase) GetSensor

func (db *SqliteDevicesDatabase) GetSensor(deviceId, sensorId string) (*sensor.Sensor, error)

func (*SqliteDevicesDatabase) GetSensorValuesSince

func (db *SqliteDevicesDatabase) GetSensorValuesSince(deviceId, sensorId string, timestamp time.Time) ([]value.SensorValue, error)

func (*SqliteDevicesDatabase) ListCommands

func (db *SqliteDevicesDatabase) ListCommands(deviceId string) ([]command.Command, error)

func (*SqliteDevicesDatabase) ListDevices

func (db *SqliteDevicesDatabase) ListDevices() ([]device.Device, error)

func (*SqliteDevicesDatabase) ListPollingSensors

func (db *SqliteDevicesDatabase) ListPollingSensors() ([]sensor.Sensor, error)

func (*SqliteDevicesDatabase) ListRules

func (database *SqliteDevicesDatabase) ListRules() ([]rules.Rule, error)

func (*SqliteDevicesDatabase) ListSensors

func (db *SqliteDevicesDatabase) ListSensors(deviceId string) ([]sensor.Sensor, error)

func (*SqliteDevicesDatabase) SeedDatabase

func (database *SqliteDevicesDatabase) SeedDatabase()

Jump to

Keyboard shortcuts

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