model

package
v0.4.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithDeviceID

func WithDeviceID(deviceID uint64) func(db *gorm.DB) *gorm.DB

func WithEndTime

func WithEndTime(endTime time.Time) func(db *gorm.DB) *gorm.DB

func WithOrder

func WithOrder(order string) func(db *gorm.DB) *gorm.DB

func WithStartTime

func WithStartTime(startTime time.Time) func(db *gorm.DB) *gorm.DB

Types

type CollectionData added in v0.3.3

type CollectionData struct {
	Timestamp   time.Time `gorm:"uniqueIndex:collection_record_device_id_timestamp" redis:"timestamp"`
	GeoPoint    GeoPoint  `gorm:"not null;type:geography(POINT, 4326);index:,type:gist"`
	Temperature float32
	Ph          float32
	Tsw         float32
	Tds         float32
	Oxygen      float32
}

type CollectionRecord

type CollectionRecord struct {
	ID              uint      `gorm:"primarykey"`
	DeviceID        uint64    `gorm:"uniqueIndex:collection_record_device_id_timestamp"`
	CreatedAt       time.Time `gorm:"autoCreateTime"`
	UpdatedAt       time.Time `gorm:"autoUpdateTime"`
	ReceivedAt      time.Time
	*CollectionData `gorm:"embedded"`
	PredictAndGuess *PredictAndGuess `gorm:"foreignKey:CollectionRecordID;references:ID"`
}

type GeoPoint

type GeoPoint struct {
	Lat float64 `json:"lat"`
	Lon float64 `json:"lon"`
}

func (*GeoPoint) Scan

func (p *GeoPoint) Scan(v any) (err error)

func (*GeoPoint) String

func (p *GeoPoint) String() string

func (GeoPoint) Value

func (p GeoPoint) Value() (driver.Value, error)

type PredictAndGuess added in v0.4.3

type PredictAndGuess struct {
	ID                 uint              `gorm:"primarykey"`
	CollectionRecordID uint              `gorm:"uniqueIndex;not null"`
	DeviceID           uint64            `gorm:"not null"`
	CreatedAt          time.Time         `gorm:"autoCreateTime"`
	UpdatedAt          time.Time         `gorm:"autoUpdateTime"`
	Level              int64             `gorm:"default:-1"`
	Predicts           []*CollectionData `gorm:"serializer:fastjson"`
	Levles             []int64           `gorm:"serializer:fastjson"`
}

func (*PredictAndGuess) AfterCreate added in v0.4.3

func (p *PredictAndGuess) AfterCreate(tx *gorm.DB) (err error)

更新CollectionRecord的UpdatedAt

func (*PredictAndGuess) AfterUpdate added in v0.4.3

func (p *PredictAndGuess) AfterUpdate(tx *gorm.DB) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL