This commit is contained in:
2023-12-01 09:32:45 +01:00
parent afbc3d3454
commit aa062a79ab
3 changed files with 110 additions and 0 deletions

View File

@ -0,0 +1,41 @@
package database
import "time"
import "gorm.io/gorm"
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"`
Attributes map[string]string `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 SensorType struct {
gorm.Model
Label string `gorm:"not null"`
Variable string `gorm:"not null"`
Unit string
Attributes map[string]string `gorm:"serializer:json;type:jsonb"`
}
type Sensor struct {
gorm.Model
Label string `gorm:"not null"`
ApplicationID int `gorm:"not null"`
Application Application
SensorTypeID int `gorm:"not null"`
SensorType SensorType
Attributes map[string]string `gorm:"serializer:json;type:jsonb"`
}