storage

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package storage provides functionality to interact with a SQLite database to store task-related data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Storage

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

Storage represents the database storage.

func NewStorage

func NewStorage(dbFile string) (*Storage, error)

NewStorage initializes a new database storage with the provided database file. It opens a connection to the SQLite database file specified by dbFile and creates a "tasks" table if it doesn't exist.

func (*Storage) AddTask

func (s *Storage) AddTask(task *util.Task) (int, error)

AddTask adds a new task to the database storage. It takes a pointer to a util.Task as input and inserts the task details into the "tasks" table. It returns the ID of the newly inserted task and any error encountered.

func (*Storage) Close

func (s *Storage) Close() error

Close closes the database connection. It returns any error encountered during closing the connection.

func (*Storage) DeleteTask

func (s *Storage) DeleteTask(id int) error

DeleteTask deletes a task with the specified ID from the database storage. It returns any error encountered during deletion.

func (*Storage) GetTask

func (s *Storage) GetTask(id int) (*util.Task, error)

GetTask retrieves a task with the specified ID from the database storage. It returns a pointer to the retrieved task and any error encountered. If no task is found with the specified ID, it returns nil for the task and nil error.

func (*Storage) ListTasks

func (s *Storage) ListTasks() ([]util.Task, error)

ListTasks retrieves a list of all tasks stored in the database storage. It returns a slice containing all tasks and any error encountered during retrieval.

func (*Storage) UpdateTask

func (s *Storage) UpdateTask(task *util.Task) error

UpdateTask updates an existing task in the database storage. It takes a pointer to a util.Task containing the updated task details and updates the corresponding task in the "tasks" table. It returns any error encountered during the update.

Jump to

Keyboard shortcuts

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