first handler writing to database
This commit is contained in:
@ -3,15 +3,20 @@ 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"`
|
||||
SensorType string `gorm:"not null"`
|
||||
Sensor string `gorm:"not null"`
|
||||
Variable string `gorm:"not null"`
|
||||
Unit string
|
||||
Value float32 `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 {
|
||||
@ -20,21 +25,21 @@ type Application struct {
|
||||
Attributes map[string]string `gorm:"serializer:json;type:jsonb"`
|
||||
}
|
||||
|
||||
type SensorType struct {
|
||||
|
||||
type DeviceType struct {
|
||||
gorm.Model
|
||||
Label string `gorm:"not null"`
|
||||
Variable string `gorm:"not null"`
|
||||
Unit string
|
||||
ModelIdentifier string
|
||||
Attributes map[string]string `gorm:"serializer:json;type:jsonb"`
|
||||
}
|
||||
|
||||
type Sensor struct {
|
||||
type Device struct {
|
||||
gorm.Model
|
||||
Label string `gorm:"not null"`
|
||||
ApplicationID int `gorm:"not null"`
|
||||
Application Application
|
||||
SensorTypeID int `gorm:"not null"`
|
||||
SensorType SensorType
|
||||
DeviceTypeID int `gorm:"not null"`
|
||||
DeviceType DeviceType
|
||||
Attributes map[string]string `gorm:"serializer:json;type:jsonb"`
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user