Documentation ¶
Index ¶
- type Controller
- func (c *Controller) CreateUser(ctx context.Context, u UserRequest) (int, error)
- func (c *Controller) DeleteUser(ctx context.Context, u UserRequest) error
- func (c *Controller) GetAllUsers(ctx context.Context) ([]UserRequest, error)
- func (c *Controller) GetUserWithID(ctx context.Context, id int) (UserRequest, error)
- func (c *Controller) Shutdown() error
- func (c *Controller) UpdateCrossoverTime(ctx context.Context, id int, updated time.Time) error
- type UserRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is a container for the SQL backend connection.
func NewController ¶
func NewController(conn *sql.DB) (*Controller, error)
NewController verifies the connection with the SQL backend and returns a new instance of a Controller.
func (*Controller) CreateUser ¶
func (c *Controller) CreateUser(ctx context.Context, u UserRequest) (int, error)
CreateUser creates a new user from a request.
func (*Controller) DeleteUser ¶
func (c *Controller) DeleteUser(ctx context.Context, u UserRequest) error
DeleteUser deletes a user that has a matching push url, public, and private keys.
func (*Controller) GetAllUsers ¶
func (c *Controller) GetAllUsers(ctx context.Context) ([]UserRequest, error)
GetAllUsers returns a list of all users from the database.
func (*Controller) GetUserWithID ¶
func (c *Controller) GetUserWithID(ctx context.Context, id int) (UserRequest, error)
GetUserWithID returns the user with the matching ID, if they exist.
func (*Controller) Shutdown ¶
func (c *Controller) Shutdown() error
Shutdown closes the database connection.
func (*Controller) UpdateCrossoverTime ¶
UpdateCrossoverTime updates the last_notification column in the database for a specific user.
type UserRequest ¶
type UserRequest struct { ID int `json:"-"` Subscription *webpush.Subscription `json:"subscription"` Longitude float64 `json:"longitude"` Latitude float64 `json:"latitude"` AQIThreshold float64 `json:"threshold"` LastCrossover null.Time `json:"-"` }
UserRequest is a container for storing details about a user from a request object.