Documentation ¶
Overview ¶
Package repo contains a database persistence strategy for our domain models. All interactions with the database should be implemented in this package; no higher-level concept (e.g. request handlers) should execute database queries directly.
The repo package contains unit tests that are executed against an actual database instance, provided by Docker Compose. This gives us confidence that our repo code actually works, ensuring that our queries are valid, and our model mapping is correct.
Index ¶
- type Client
- func (c *Client) CreateAccount(ctx context.Context, a *domain.Account) (*domain.Account, error)
- func (c *Client) CreateTask(ctx context.Context, t *domain.Task) (*domain.Task, error)
- func (c *Client) DeleteTaskByIDAndAccountID(ctx context.Context, taskID, accountID int64) error
- func (c *Client) GetAccountByID(ctx context.Context, id int64) (*domain.Account, error)
- func (c *Client) GetAccountByUsername(ctx context.Context, username string) (*domain.Account, error)
- func (c *Client) GetAllTasksByAccountID(ctx context.Context, accountID int64) ([]*domain.Task, error)
- func (c *Client) GetTaskByIDAndAccountID(ctx context.Context, taskID, accountID int64) (*domain.Task, error)
- func (c *Client) MarkIncompleteTasksCompleteByAccountID(ctx context.Context, accountID int64) (int64, error)
- func (c *Client) UpdateTask(ctx context.Context, t *domain.Task) (*domain.Task, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client provides access to all supported database interactions.
func (*Client) CreateAccount ¶
CreateAccount inserts an account into the database.
func (*Client) CreateTask ¶
CreateTask inserts a task into the database.
func (*Client) DeleteTaskByIDAndAccountID ¶
DeleteTask deletes a task from the database.
func (*Client) GetAccountByID ¶
GetAccountByID fetches an account by id from the database or returns nil if not found.
func (*Client) GetAccountByUsername ¶
func (c *Client) GetAccountByUsername(ctx context.Context, username string) (*domain.Account, error)
GetAccountByUsername fetches an account by username from the database or returns nil if not found.
func (*Client) GetAllTasksByAccountID ¶
func (c *Client) GetAllTasksByAccountID(ctx context.Context, accountID int64) ([]*domain.Task, error)
GetAllTasksByAccountID fetches all tasks by account from the database.
func (*Client) GetTaskByIDAndAccountID ¶
func (c *Client) GetTaskByIDAndAccountID(ctx context.Context, taskID, accountID int64) (*domain.Task, error)
GetTaskByIDAndAccountID fetches a task by ID and account from the database, or returns nil if not found.