universal-data-ingest/src/udi/database/abstract_database.go

47 lines
1.0 KiB
Go

package database
import "time"
import "gorm.io/gorm"
type VariableType struct {
Label string `json:"label"`
Variable string `json:"variable"`
Unit string `json:"unit"`
Value interface{} `json:"value,omitempty"`
}
type Measurement struct {
Time time.Time `gorm:"not null;primary_key"`
Application string `gorm:"not null"`
Device string
Attributes map[string]string `gorm:"serializer:json;type:jsonb"`
Values map[string]VariableType `gorm:"serializer:json;type:jsonb"`
}
type Application struct {
gorm.Model
Label string `gorm:"not null"`
Attributes map[string]string `gorm:"serializer:json;type:jsonb"`
}
type DeviceType struct {
gorm.Model
Label string `gorm:"not null"`
ModelIdentifier string
Attributes map[string]string `gorm:"serializer:json;type:jsonb"`
}
type Device struct {
gorm.Model
Label string `gorm:"not null"`
ApplicationID int `gorm:"not null"`
Application Application
DeviceTypeID int `gorm:"not null"`
DeviceType DeviceType
Attributes map[string]string `gorm:"serializer:json;type:jsonb"`
}