40 lines
1.6 KiB
Go
40 lines
1.6 KiB
Go
package db
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/go-flucky/flucky/pkg/types"
|
|
)
|
|
|
|
type Database interface {
|
|
|
|
// Close DB Connction
|
|
Close() error
|
|
|
|
// 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)
|
|
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
|
|
}
|