sql

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

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

func (c *Controller) UpdateCrossoverTime(ctx context.Context, id int, updated time.Time) error

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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