Documentation
¶
Index ¶
- Variables
- func AddTask(t Task) error
- func BackupDB() error
- func CheckTaskExists(id int) error
- func CloseDB() error
- func CompleteTask(id int) error
- func InitDB() error
- func RemoveTask(id int) error
- func ReopenTask(id int) error
- func RestoreBackup() error
- func SetDue(id int, newDate string) error
- func SetTitle(id int, newTitle string) error
- func TogglePriority(id int) error
- type Task
Constants ¶
This section is empty.
Variables ¶
var DB *sql.DB
DB is a global variable representing the database connection
Functions ¶
func BackupDB ¶
func BackupDB() error
BackupDB creates a backup copy of the current SQLite database file ("tasks.db"). It reads the original database file and writes its contents to a new file "tasks.db.bak".
func CheckTaskExists ¶
CheckTaskExists checks if a task with the given ID exists in the database. It returns an error if the task does not exist or if there is a query error.
func CloseDB ¶
func CloseDB() error
CloseDB safely closes the database connection, if it had been opened. it returns any error encountered during close, and if the DB was never initialised, it returns nil this function is always called on exit of tidytask
func CompleteTask ¶
CompleteTask marks the task with the specified ID in the database as complete
func InitDB ¶
func InitDB() error
InitDB creates the SQLite database by creating the database file and the tasks table if it does not exist
func RemoveTask ¶
RemoveTask deletes the task with the specified ID from the database.
func ReopenTask ¶
ReopenTask updates the task with the given ID to mark it as open (incomplete) it sets the 'complete' field to false and clears complete_date
func RestoreBackup ¶
func RestoreBackup() error
RestoreBackup replaces the current database file with the backup copy. After successfully restoring, it deletes the backup file.
func SetDue ¶
SetDue updates the due date of the task identified by the given ID. it sets the task's due field to the provided newDate string
func SetTitle ¶
SetTitle updates the due date of the task identified by the given ID. it sets the task's title field to the provided newTitle string
func TogglePriority ¶
TogglePriority flips the priority status of the task identified by the given ID.
Types ¶
type Task ¶
type Task struct {
ID int `json:"id"` // Unique ID for task (primary key)
Title string `json:"title"` // Title or description of the task (mandatory)
Due string `json:"due"` // Due date as string (empty string represents no due set)
Complete bool `json:"complete"` // Flag indicating the tasks completion status
CompleteDate sql.NullString `json:"complete_date"` // Nullable date string representing when task was completed
Priority bool `json:"priority"` // Flag indicating if the task is marked as high priority
}
Task represents a to-do list task