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

42 lines
989 B
Go
Raw Normal View History

2023-12-01 09:32:45 +01:00
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"`
}