database

package
v0.0.0-...-47b3246 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SpaceContext             string = "https://dev.realestatecore.io/contexts/Space.jsonld"
	SpaceType                string = "dtmi:org:w3id:rec:Space;1"
	SpaceTypeName            string = "space"
	BuildingContext          string = "https://dev.realestatecore.io/contexts/Building.jsonld"
	BuildingType             string = "dtmi:org:w3id:rec:Building;1"
	BuildingTypeName         string = "building"
	SensorContext            string = "https://dev.realestatecore.io/contexts/Sensor.jsonld"
	SensorType               string = "dtmi:org:brickschema:schema:Brick:Sensor;1"
	SensorTypeName           string = "sensor"
	ObservationEventContext  string = "https://dev.realestatecore.io/contexts/ObservationEvent.jsonld"
	ObservationEventType     string = "dtmi:org:w3id:rec:ObservationEvent;1"
	ObservationEventTypeName string = "observationevent"
)

Variables

This section is empty.

Functions

func GetTypeFromTypeName

func GetTypeFromTypeName(typeName string) string

Types

type Config

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

func LoadConfiguration

func LoadConfiguration(ctx context.Context) Config

func NewConfig

func NewConfig(host, user, password, port, dbname, sslmode string) Config

func (Config) ConnStr

func (c Config) ConnStr() string

type Database

type Database interface {
	Init(ctx context.Context) error
	Seed(ctx context.Context, reader io.Reader) error
	AddEntity(ctx context.Context, e Entity) error
	GetEntity(ctx context.Context, entityID, entityType string) (Entity, error)
	GetEntities(ctx context.Context, entityType string, page, size int) (int64, []Entity, error)
	GetChildEntities(ctx context.Context, root Entity, entityType string) ([]Entity, error)
	AddObservation(ctx context.Context, so SensorObservation) error
	GetObservations(ctx context.Context, sensorId string, starting, ending time.Time, page, size int) (int64, []Observation, error)
}

func Connect

func Connect(ctx context.Context, cfg Config) (Database, error)

type Entity

type Entity struct {
	Context  string    `json:"@context"`
	Id       string    `json:"@id"`
	Type     string    `json:"@type"`
	IsPartOf *Property `json:"isPartOf,omitempty"`
}

type Observation

type Observation struct {
	ObservationTime time.Time `json:"observationTime"`
	Value           *float64  `json:"value,omitempty"`
	ValueString     *string   `json:"valueString,omitempty"`
	ValueBoolean    *bool     `json:"valueBoolean,omitempty"`
	QuantityKind    string    `json:"quantityKind"`
	SensorId        string    `json:"sensorId"`
}

type Property

type Property struct {
	Id   string `json:"@id"`
	Type string `json:"@type"`
}

type SensorObservation

type SensorObservation struct {
	Format       string        `json:"format"`
	DeviceID     string        `json:"deviceId"`
	Observations []Observation `json:"observations"`
}

Jump to

Keyboard shortcuts

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