The main server, and probably only repository in this org.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.4 KiB

  1. package models
  2. import "context"
  3. // A Button is general information about a button that exists.
  4. type Button struct {
  5. ID int `db:"id" json:"id"`
  6. BridgeID int `db:"bridge_id" json:"bridgeId"`
  7. InternalIndex int `db:"internal_index" json:"internalIndex"`
  8. InternalID string `db:"internal_id" json:"internalId"`
  9. TargetGroupID int `db:"target_group_id" json:"targetGroupId"`
  10. Name string `db:"name" json:"name"`
  11. Kind string `db:"kind" json:"kind"`
  12. Missing bool `db:"missing" json:"missing"`
  13. NumButtons int `db:"num_buttons" json:"numButtons"`
  14. }
  15. // ButtonEvent is an event.
  16. type ButtonEvent struct {
  17. Index int
  18. Kind string
  19. }
  20. const (
  21. // ButtonEventKindPress is a button event.
  22. ButtonEventKindPress = "press"
  23. // ButtonEventKindRepeat is a button event.
  24. ButtonEventKindRepeat = "repeat"
  25. // ButtonEventKindRelease is a button event.
  26. ButtonEventKindRelease = "release"
  27. )
  28. // ButtonRepository is an interface for all database operations
  29. // related to the button model.
  30. type ButtonRepository interface {
  31. FindByID(ctx context.Context, id int) (Button, error)
  32. FindByInternalID(ctx context.Context, internalID string) (Button, error)
  33. List(ctx context.Context) ([]Button, error)
  34. ListByBridge(ctx context.Context, bridge Bridge) ([]Button, error)
  35. Insert(ctx context.Context, button Button) (Button, error)
  36. Update(ctx context.Context, button Button) error
  37. Remove(ctx context.Context, button Button) error
  38. }