db

package
v0.0.0-...-baaaa93 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBOType

type DBOType string
const (
	DBOTypePostgres DBOType = "postgres"
	DBOTypeOracle           = "oracle"
)

func (DBOType) String

func (dboType DBOType) String() string

type Database

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
}

func New

func New(dboType DBOType, host string, port string, database string, user string, password string) (Database, error)

type Postgres

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

func (*Postgres) Close

func (p *Postgres) Close() error

func (*Postgres) DeleteDevices

func (p *Postgres) DeleteDevices(ctx context.Context, devices []*types.Device) error

func (*Postgres) DeleteMeasuredValues

func (p *Postgres) DeleteMeasuredValues(ctx context.Context, measuredValues []*types.MeasuredValue) error

func (*Postgres) DeleteSensors

func (p *Postgres) DeleteSensors(ctx context.Context, sensors []*types.Sensor) error

func (*Postgres) InsertDevices

func (p *Postgres) InsertDevices(ctx context.Context, devices []*types.Device) error

func (*Postgres) InsertMeasuredValues

func (p *Postgres) InsertMeasuredValues(ctx context.Context, measuredValues []*types.MeasuredValue) error

func (*Postgres) InsertSensors

func (p *Postgres) InsertSensors(ctx context.Context, sensors []*types.Sensor) error

func (*Postgres) SelectDeviceByID

func (p *Postgres) SelectDeviceByID(ctx context.Context, id string) (*types.Device, error)

func (*Postgres) SelectHumidities

func (p *Postgres) SelectHumidities(ctx context.Context) ([]*types.MeasuredValue, error)

func (*Postgres) SelectHumidityByID

func (p *Postgres) SelectHumidityByID(ctx context.Context, id string) (*types.MeasuredValue, error)

func (*Postgres) SelectMeasuredValuesByIDAndType

func (p *Postgres) SelectMeasuredValuesByIDAndType(ctx context.Context, id string, valueType types.MeasuredValueType) (*types.MeasuredValue, error)

func (*Postgres) SelectPressureByID

func (p *Postgres) SelectPressureByID(ctx context.Context, id string) (*types.MeasuredValue, error)

func (*Postgres) SelectPressures

func (p *Postgres) SelectPressures(ctx context.Context) ([]*types.MeasuredValue, error)

func (*Postgres) SelectSensorByID

func (p *Postgres) SelectSensorByID(ctx context.Context, id string) (*types.Sensor, error)

func (*Postgres) SelectTemperatureByID

func (p *Postgres) SelectTemperatureByID(ctx context.Context, id string) (*types.MeasuredValue, error)

func (*Postgres) SelectTemperatures

func (p *Postgres) SelectTemperatures(ctx context.Context) ([]*types.MeasuredValue, error)

func (*Postgres) UpdateDevices

func (p *Postgres) UpdateDevices(ctx context.Context, devices []*types.Device) error

func (*Postgres) UpdateMeasuredValues

func (p *Postgres) UpdateMeasuredValues(ctx context.Context, measuredValues []*types.MeasuredValue) error

func (*Postgres) UpdateSensors

func (p *Postgres) UpdateSensors(ctx context.Context, sensots []*types.Sensor) error

Jump to

Keyboard shortcuts

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