PKGBUILD/pkg/storage/db/interfaces.go

49 lines
2.0 KiB
Go
Raw Normal View History

2019-08-20 19:37:45 +00:00
package db
import (
"context"
"github.com/Masterminds/semver"
"github.com/volker-raschek/flucky/pkg/types"
2019-08-20 19:37:45 +00:00
)
type Database interface {
// Close DB Connction
Close() error
// Schema
Schema(ctx context.Context, version *semver.Version) error
2019-08-20 19:37:45 +00:00
// Delete
DeleteDevices(ctx context.Context, devices []*types.Device) error
2020-01-18 13:42:15 +00:00
DeleteInfo(ctx context.Context, key string) error
2019-08-20 19:37:45 +00:00
DeleteMeasuredValues(ctx context.Context, measuredValues []*types.MeasuredValue) error
DeleteSensors(ctx context.Context, sensors []*types.Sensor) error
// Insert
InsertDevices(ctx context.Context, devices []*types.Device) error
2020-01-18 13:42:15 +00:00
InsertInfo(ctx context.Context, key string, value string) error
2019-08-20 19:37:45 +00:00
InsertMeasuredValues(ctx context.Context, measuredValues []*types.MeasuredValue) error
InsertSensors(ctx context.Context, sensors []*types.Sensor) error
// Select
SelectDeviceByID(ctx context.Context, id string) (*types.Device, error)
SelectHumidities(ctx context.Context) ([]*types.MeasuredValue, error)
SelectHumidityByID(ctx context.Context, id string) (*types.MeasuredValue, error)
2020-01-18 13:42:15 +00:00
SelectInfo(ctx context.Context, key string) (string, error)
SelectMeasuredValues(ctx context.Context) ([]*types.MeasuredValue, error)
2019-08-20 19:37:45 +00:00
SelectMeasuredValuesByIDAndType(ctx context.Context, id string, valueType types.MeasuredValueType) (*types.MeasuredValue, error)
SelectPressures(ctx context.Context) ([]*types.MeasuredValue, error)
SelectPressureByID(ctx context.Context, id string) (*types.MeasuredValue, error)
SelectSensorByID(ctx context.Context, id string) (*types.Sensor, error)
SelectTemperatures(ctx context.Context) ([]*types.MeasuredValue, error)
SelectTemperatureByID(ctx context.Context, id string) (*types.MeasuredValue, error)
// Update
UpdateDevices(ctx context.Context, devices []*types.Device) error
2020-01-18 13:42:15 +00:00
UpdateInfo(ctx context.Context, key string, value string) error
2019-08-20 19:37:45 +00:00
UpdateMeasuredValues(ctx context.Context, measuredValues []*types.MeasuredValue) error
UpdateSensors(ctx context.Context, sensots []*types.Sensor) error
}