model

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 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 WithPageAndPageSize

func WithPageAndPageSize(page, pageSize int) func(db *gorm.DB) *gorm.DB

func WithStartTime

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

Types

type Collection

type Collection struct {
	DeviceID  uint64    `gorm:"primarykey"`
	Timestamp time.Time `gorm:"primarykey"`
	CreatedAt time.Time `gorm:"autoCreateTime"`
	GeoPoint  GeoPoint  `gorm:"not null;type:geometry"`
}

type Device

type Device struct {
	Mac         string       `gorm:"primarykey"`
	DeviceID    uint64       `gorm:"not null;uniqueIndex"`
	Collections []Collection `gorm:"foreignKey:DeviceID;references:DeviceID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	Logs        []DeviceLog  `gorm:"foreignKey:DeviceID;references:DeviceID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	CreatedAt   time.Time    `gorm:"autoCreateTime"`
	UpdatedAt   time.Time    `gorm:"autoUpdateTime"`
}

type DeviceLog added in v0.1.1

type DeviceLog struct {
	DeviceID  uint64    `gorm:"not null;index"`
	CreatedAt time.Time `gorm:"autoCreateTime"`
	Timestamp time.Time `gorm:"not null;index"`
	Level     logrus.Level
	Message   string
}

type GeoPoint

type GeoPoint struct {
	Lat float64 `json:"lat"`
	Lng float64 `json:"lng"`
}

func (*GeoPoint) Scan

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

func (*GeoPoint) String

func (p *GeoPoint) String() string

func (GeoPoint) Value

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

Jump to

Keyboard shortcuts

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