db

package
v0.0.0-...-18142e2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCategory

func AddCategory(username, category string) error

AddCategory is used to add the task in the database

func AddComments

func AddComments(username string, id int, comment string) error

AddComments will be used to add comments in the database

func AddFile

func AddFile(fileName, token, username string) error

AddFile is used to add the md5 of a file name which is uploaded to our application this will enable us to randomize the URL without worrying about the file names

func AddTask

func AddTask(title, content, category string, taskPriority int, username string, hidden int) error

AddTask is used to add the task in the database TODO: add dueDate feature later

func Close

func Close()

Close function closes this database connection

func CompleteTask

func CompleteTask(username string, id int) error

CompleteTask is used to mark tasks as complete

func CreateUser

func CreateUser(username, password, email string) error

CreateUser will create a new user, take as input the parameters and insert it into database

func DeleteAll

func DeleteAll(username string) error

DeleteAll is used to empty the trash

func DeleteCategoryByName

func DeleteCategoryByName(username, category string) error

DeleteCategoryByName will be used to delete a category from the category page

func DeleteCommentByID

func DeleteCommentByID(username string, id int) error

DeleteCommentByID will actually delete the comment from db

func DeleteTask

func DeleteTask(username string, id int) error

DeleteTask is used to delete the task from the database

func GetCategories

func GetCategories(username string) []types.CategoryCount

GetCategories will return the list of categories to be rendered in the template

func GetCategoryByName

func GetCategoryByName(username, category string) int

GetCategoryByName will return the ID of that category passed as args used while inserting tasks into the table

func GetCategoryIDByName

func GetCategoryIDByName(username string, category string) int

GetCategoryIDByName will return the category ID for the category, used in the edit task function where we need to be able to update the categoryID of the task

func GetComments

func GetComments(username string) (map[int][]types.Comment, error)

GetComments is used to get comments, all of them. We do not want 100 different pages to show tasks, we want to use as few pages as possible so we are going to populate everything on the damn home pages

func GetFileName

func GetFileName(token string) (string, error)

GetFileName is used to fetch the name according to the md5 checksum from the db

func GetTaskByID

func GetTaskByID(username string, id int) (types.Context, error)

GetTaskByID function gets the tasks from the ID passed to the function, used to populate EditTask

func GetTasks

func GetTasks(username, status, category string) (types.Context, error)

GetTasks retrieves all the tasks depending on the status pending or trashed or completed

func GetUserID

func GetUserID(username string) (int, error)

GetUserID will get the user's ID from the database

func RestoreTask

func RestoreTask(username string, id int) error

RestoreTask is used to restore tasks from the Trash

func RestoreTaskFromComplete

func RestoreTaskFromComplete(username string, id int) error

RestoreTaskFromComplete is used to restore tasks from the Trash

func SearchTask

func SearchTask(username, query string) (types.Context, error)

SearchTask is used to return the search results depending on the query

func TrashTask

func TrashTask(username string, id int) error

TrashTask is used to delete the task

func UpdateCategoryByName

func UpdateCategoryByName(username, oldName, newName string) error

UpdateCategoryByName will be used to delete a category from the category page

func UpdateTask

func UpdateTask(id int, title, content, category string, priority int, username string, hidden int) error

UpdateTask is used to update the tasks in the database

func ValidUser

func ValidUser(username, password string) bool

ValidUser will check if the user exists in db and if exists if the username password combination is valid

Types

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database encapsulates database

Jump to

Keyboard shortcuts

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