42 lines
989 B
Go
42 lines
989 B
Go
|
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"`
|
||
|
}
|
||
|
|
||
|
|