2019-08-20 19:37:45 +00:00
|
|
|
package db
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2019-09-01 10:27:06 +00:00
|
|
|
"github.com/Masterminds/semver"
|
2019-08-20 19:37:45 +00:00
|
|
|
"github.com/go-flucky/flucky/pkg/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Database interface {
|
|
|
|
|
|
|
|
// Close DB Connction
|
|
|
|
Close() error
|
|
|
|
|
2019-09-01 10:27:06 +00:00
|
|
|
// 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
|
|
|
|
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
|
|
|
|
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)
|
2019-12-07 15:53:49 +00:00
|
|
|
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
|
|
|
|
UpdateMeasuredValues(ctx context.Context, measuredValues []*types.MeasuredValue) error
|
|
|
|
UpdateSensors(ctx context.Context, sensots []*types.Sensor) error
|
|
|
|
}
|