db

package
v1.2.3-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *sql.DB

Functions

func AssignJobLabel

func AssignJobLabel(jobId int64, labelId int64) (*int64, error)

AssignJobLabel Takes job id and task id, creates job_label in db, returns id

func ConnectDatabase

func ConnectDatabase(filename string) (*sql.DB, error)

ConnectDatabase Use sqlite pkg to establish a connection

func CreateAlert

func CreateAlert(newAlert models.NewAlert) (*int64, error)

CreateAlert Takes newAlert, creates in db, returns id

func CreateDatabase

func CreateDatabase(filename string, sqlString string) error

CreateDatabase

func CreateJob

func CreateJob(newJob models.NewJob) (*int64, error)

CreateJob Takes newJob, creates in db, returns id

func CreateLabel

func CreateLabel(newLabel models.NewLabel) (*int64, error)

CreateLabel Takes newLabel, creates in db, returns id

func CreateTask

func CreateTask(newTask models.NewTask, jobId int64) (*int64, error)

CreateTask Takes newTask, creates in db, returns id

func CreateUser

func CreateUser(newUser models.NewUser, password *[]byte) (*int64, error)

CreateUser Take NewUser and hashed PW as arguments, insert them into db

func CreateVehicle

func CreateVehicle(newVehicle models.NewVehicle) (*int64, error)

CreateVehicle Takes newVehicle, creates in db, returns id

func DeleteAlert

func DeleteAlert(alertId int64, userId *int64) error

DeleteAlert Take alert id as arg, delete Alert from alert table where id present

func DeleteJob

func DeleteJob(jobId int64, userId *int64) error

DeleteJob Take job id as arg, delete Job from job table where id present

func DeleteLabel

func DeleteLabel(labelId int64, userId *int64) error

DeleteLabel Take label id as arg, delete Label from label table where id present

func DeleteTask

func DeleteTask(jobId int64, taskId *int64) error

DeleteTask Take task id as arg, delete Task from task table where id present

func DeleteUser

func DeleteUser(username string) error

DeleteUser Take username as arg, delete User from user table where username present

func DeleteVehicle

func DeleteVehicle(vehicleId int64, userId *int64) error

DeleteVehicle Take vehicle id as arg, delete Vehicle from vehicle table where id present

func EditAlert

func EditAlert(editedAlert models.Alert) error

EditAlert Take Alert as arg, build update query with QueryBuilder, update it in db via generated query

func EditJob

func EditJob(editedJob models.Job) error

EditJob Take Job as arg, build update query with QueryBuilder, update it in db via generated query

func EditLabel

func EditLabel(editedLabel models.Label) error

EditLabel Take Label as arg, build update query with QueryBuilder, update it in db via generated query

func EditTask

func EditTask(editedTask models.Task, jobId int64) error

EditTask Take Task as arg, build update query with QueryBuilder, update it in db via generated query

func EditUser

func EditUser(editedUser models.User) error

EditUser Take User as arg, update it in db

func EditVehicle

func EditVehicle(editedVehicle models.Vehicle) error

EditVehicle Take Vehicle as arg, build update query with QueryBuilder, update it in db via generated query

func GetAlert

func GetAlert(alertId int64) (*models.Alert, error)

GetAlert Takes alert id, queries it in db, returns Alert

func GetAuthInfoByUsername

func GetAuthInfoByUsername(username string) (*int64, *string, *int, *[]byte, error)

GetAuthInfoByUsername Take username, retrieve auth info: user ID, isAdmin and the hashed password

func GetJob

func GetJob(jobId int64) (*models.Job, error)

GetJob Takes job id, queries it in db, returns Job

func GetLabel

func GetLabel(labelId int64) (*models.Label, error)

GetLabel Takes label id, queries it in db, returns Label

func GetTask

func GetTask(jobId int64, taskId int64) (*models.Task, error)

GetTask Takes job id, queries it in db, returns Task

func GetUserById

func GetUserById(userId int64) (*models.User, error)

GetUserById Take user ID, return entire user

func GetUserByUsername

func GetUserByUsername(username string) (*models.User, error)

GetUserByUsername Take username, return entire user

func GetVehicle

func GetVehicle(vehicleId int64) (*models.Vehicle, error)

GetVehicle Takes vehicle id, queries it in db, returns vehicle

func LabelProcessor

func LabelProcessor(ids *string, names *string, colors *string, createdTimes *string, updatedTimes *string) ([]models.Label, error)

LabelProcessor takes label cols and convert them into slice of objects ideally this is done as service layer but doing in db layer prevents relooping through results

func ListAlerts

func ListAlerts(userId *string, vehicleId *string, jobId *string, taskId *string, typeStr *string, isRead *string, alertDate *string, searchStr *string, sort *string) ([]*models.Alert, error)

ListAlerts Take filters as args, return Alert list

func ListJobs

func ListJobs(userId *string, vehicleId *string, isTemplate *string, isComplete *string, labelId *string, searchStr *string, sort *string) ([]*models.Job, error)

ListJobs Take filters as args, return Job list

func ListLabels

func ListLabels(userId *string, jobId *string, searchStr *string, sort *string) ([]*models.Label, error)

ListLabels Take filters as args, return Label list

func ListTasks

func ListTasks(jobId int64, isComplete *string, searchStr *string, sort *string) ([]*models.Task, error)

ListTasks Take filters as args, return Task list

func ListUsers

func ListUsers(jobId *string, vehicleId *string, isAdmin *string, searchStr *string, sort *string) ([]*models.User, error)

ListUsers Take filters as args, return User list

func ListVehicles

func ListVehicles(userId *string, jobId *string, searchStr *string, sort *string) ([]*models.Vehicle, error)

ListVehicles Take filters as args, return Vehicle list

func QueryBuilder

func QueryBuilder(query string, joins *[]string, wheres *[]string, likes *[]Like, groupBy *string, sort *string) string

QueryBuilder Take basic parts of SQL query, construct into usable query May need ORM in the future if it gets too complex, but should work fine for basic queries used thus far

func UnassignJobLabel

func UnassignJobLabel(jobId int64, labelId int64) error

UnassignJobLabel Takes job id and task id, deletes job_label entry in db if its exists

func UpdatePassword

func UpdatePassword(username string, password *[]byte) error

UpdatePassword Take username and hashed pw as args, update it in db

func UpdateTaskStatus

func UpdateTaskStatus(jobId int64, taskId int64, status int) error

UpdateTaskStatus Take job id, task id, status as args, build update query with QueryBuilder, update it in db via generated query

func UpdatedAlertStatus

func UpdatedAlertStatus(alertId int64, userId int64, status int) error

UpdatedAlertStatus Take alert id, user id, status as args, build update query with QueryBuilder, update it in db via generated query

Types

type Like

type Like struct {
	Fields []string `json:"fields"`
	Match  string   `json:"match"`
	Or     bool     `json:"or"`
}

type Like Used by QueryBuilder

Jump to

Keyboard shortcuts

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