增加 timescaledb 处理逻辑和gin索引
This commit is contained in:
@@ -10,19 +10,19 @@ import (
|
||||
type SensorData struct {
|
||||
// Time 是数据记录的时间戳,作为复合主键的一部分。
|
||||
// GORM 会将其映射到 'time' TIMESTAMPTZ 列。
|
||||
Time time.Time `gorm:"primaryKey"`
|
||||
Time time.Time `gorm:"primaryKey" json:"time"`
|
||||
|
||||
// DeviceID 是传感器的唯一标识符,作为复合主键的另一部分。
|
||||
// GORM 会将其映射到 'device_id' VARCHAR(50) 列。
|
||||
DeviceID string `gorm:"primaryKey;size:50"`
|
||||
DeviceID uint `gorm:"primaryKey" json:"device_id"`
|
||||
|
||||
// RegionalControllerID 是上报此数据的区域主控的ID。
|
||||
// 我们为其添加了数据库索引以优化按区域查询的性能。
|
||||
RegionalControllerID string `gorm:"size:50;index"`
|
||||
RegionalControllerID uint `json:"regional_controller_id"`
|
||||
|
||||
// Data 存储一个或多个传感器读数,格式为 JSON。
|
||||
// GORM 会使用 'jsonb' 类型来创建此列。
|
||||
Data datatypes.JSON `gorm:"type:jsonb"`
|
||||
Data datatypes.JSON `gorm:"type:jsonb" json:"data"`
|
||||
}
|
||||
|
||||
func (SensorData) TableName() string {
|
||||
|
||||
Reference in New Issue
Block a user