Documentation ¶
Index ¶
- func NewTaskRepository(tasks map[int]*task.Task, DB DatabaseHandler) task.TaskRepository
- type DatabaseHandler
- type PostgresHandler
- func (handler *PostgresHandler) CheckTask(id int) error
- func (handler *PostgresHandler) CreateNewTask(name string) error
- func (handler *PostgresHandler) DeleteTask(id int) error
- func (handler *PostgresHandler) GetAllTasks() (map[int]*task.Task, error)
- func (handler *PostgresHandler) GetConnection(conString string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTaskRepository ¶
func NewTaskRepository(tasks map[int]*task.Task, DB DatabaseHandler) task.TaskRepository
NewTaskRepository returns a new repository initialized with the given tasks and database handler
Types ¶
type DatabaseHandler ¶
type DatabaseHandler interface { // GetConnection stablishes connection with a given type of database GetConnection(conString string) error // GetAllTasks retrieves all tasks from a given type of database GetAllTasks() (map[int]*task.Task, error) // CreateNewTask creates a new task in a given type of database CreateNewTask(name string) error // DeleteTask deletes a given task from a given type of database DeleteTask(id int) error // CheckTask modifies a given task from a given type of database CheckTask(id int) error }
Interface for accesses to a database
type PostgresHandler ¶
Type to access a Postgresql database Implements DatabaseHandler
func NewPostgres ¶
func NewPostgres(db *sql.DB, ctx context.Context) *PostgresHandler
NewPostgres returns a new PostgresHandler element
func (*PostgresHandler) CheckTask ¶ added in v0.1.3
func (handler *PostgresHandler) CheckTask(id int) error
CheckTask marks a given task as done
func (*PostgresHandler) CreateNewTask ¶
func (handler *PostgresHandler) CreateNewTask(name string) error
CreateNewTask creates a new task in the database
func (*PostgresHandler) DeleteTask ¶
func (handler *PostgresHandler) DeleteTask(id int) error
DeleteTask deletes a given task from the database
func (*PostgresHandler) GetAllTasks ¶
func (handler *PostgresHandler) GetAllTasks() (map[int]*task.Task, error)
GetAllTasks retrieves all tasks from the database and returns a map with the tasks formatted for the application to use (type of Task)
func (*PostgresHandler) GetConnection ¶
func (handler *PostgresHandler) GetConnection(conString string) error
GetConnection stablish a connection with the database
Click to show internal directories.
Click to hide internal directories.