rule.go 639 B

123456789101112131415161718192021222324
  1. package models
  2. import (
  3. "github.com/jinzhu/gorm"
  4. )
  5. // Rule rule
  6. // rule is used for automated works such as timers, ifttts.
  7. type Rule struct {
  8. gorm.Model
  9. RecordId string `gorm:"column:record_id;size:32;index"`
  10. // which device the rule belongs to
  11. DeviceID string
  12. // rule type, timmer | ifttt
  13. RuleType string `sql:"type:varchar(20);not null;"`
  14. // which action triggers the rule
  15. Trigger string `sql:"type:varchar(200);not null;"`
  16. // where to send
  17. Target string `sql:"type:varchar(200);not null;"`
  18. // what action to take.
  19. Action string `sql:"type:varchar(200);not null;"`
  20. // if trigger once
  21. Once bool `sql:"default(false)"`
  22. }