db

package
v0.0.0-...-4bd84bf Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteDevice

func DeleteDevice(id int64, mustExist bool) error

Deletes a device, returning an error if it fails

func DeleteResponse

func DeleteResponse(id int64, mustExist bool) error

Deletes a task, returning an error if it fails

func DeleteTask

func DeleteTask(id int64, mustExist bool) error

Deletes a task, returning an error if it fails

func DeleteUser

func DeleteUser(id int64, mustExist bool) error

Deletes a user, returning an error if it fails

func GrantAccess

func GrantAccess(u User, d Device)

func Init

func Init(opts Options)

func InsertDevice

func InsertDevice(d NewDevice) (int64, error)

Inserts a device, returning the assigned ID

func InsertResponse

func InsertResponse(r NewResponse) (int64, error)

Inserts a response for a task, returning the assigned ID

func InsertTask

func InsertTask(t NewTask) (int64, error)

Inserts a task, returning the assigned ID

func InsertUser

func InsertUser(u CreateUserDTO) (int64, error)

Inserts a user, returning the assigned ID

func RevokeAccess

func RevokeAccess(u User, d Device)

Types

type Controls

type Controls struct {
	UserId   int64
	DeviceId int64
}

Represents the "controls" relationship between users and devices

type CreateUserDTO

type CreateUserDTO struct {
	Name   string
	Email  string
	Admin  bool
	Token  string
	Active bool
}

type Device

type Device struct {
	Id int64
	NewDevice
}

type NewDevice

type NewDevice struct {
	Name        string
	Description string
	Token       string
}

type NewResponse

type NewResponse struct {
	TaskId int64
	State  int16
}

type NewTask

type NewTask struct {
	Title  string
	Device int64
	State  int16
}

type Options

type Options struct {
	Driver string
	User   string
	Pass   string
	Addr   string
	DBName string
}

type Response

type Response struct {
	Id int64
	NewResponse
}

type Task

type Task struct {
	Id int64
	NewTask
}

type User

type User struct {
	Id     int64
	Name   string
	Email  string
	Admin  bool
	Token  string
	Active bool
}

func GetUser

func GetUser(id int64) (User, error)

Jump to

Keyboard shortcuts

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