Documentation ¶
Overview ¶
Package psql used for storing data in PostgreSQL database
Index ¶
- func NewDB(cfg Config) (*sql.DB, error)
- type Auth
- type Config
- type Storage
- type TodoItem
- func (r *TodoItem) CreateTodo(listID int, t core.TodoItem) (core.TodoItem, error)
- func (r *TodoItem) DeleteTodo(todoID int) error
- func (r *TodoItem) GetAllTodos(listID int) ([]core.TodoItem, error)
- func (r *TodoItem) GetTodoByID(listID, todoID int) (core.TodoItem, error)
- func (r *TodoItem) UpdateTodo(todoID int, data core.UpdateItemData) (core.TodoItem, error)
- type TodoList
- func (r *TodoList) CreateList(userID int, l core.Todolist) (core.Todolist, error)
- func (r *TodoList) DeleteList(listID int) error
- func (r *TodoList) GetAllLists(userID int) ([]core.Todolist, error)
- func (r *TodoList) GetListByID(userID, listID int) (core.Todolist, error)
- func (r *TodoList) UpdateList(listID int, data core.UpdateListData) (core.Todolist, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth represents repository for authorization and authentication
func (*Auth) CreateUser ¶
CreateUser creates new user in DB
type Config ¶
type Config struct { Host string Port string Username string Password string DBName string SSLMode string Logger *zap.Logger }
Config represents all required fields for connecting to postgres db
type Storage ¶
Storage contains all implemented repositories
func NewStorage ¶
NewStorage returns all implemented repositories
type TodoItem ¶
type TodoItem struct {
// contains filtered or unexported fields
}
TodoItem represents Todo repository
func NewTodoItem ¶
NewTodoItem returns instance of Todo repository
func (*TodoItem) CreateTodo ¶
CreateTodo creates new Todo in DB and links it to the List
func (*TodoItem) DeleteTodo ¶
DeleteTodo removes todo from DB by ID
func (*TodoItem) GetAllTodos ¶
GetAllTodos returns all todos which related to the given List
func (*TodoItem) GetTodoByID ¶
GetTodoByID returns todo by ID which related to the given list
func (*TodoItem) UpdateTodo ¶
UpdateTodo save Todo changes to the db
type TodoList ¶
type TodoList struct {
// contains filtered or unexported fields
}
TodoList represents List of todos repository
func NewTodoList ¶
NewTodoList returns instance of List repository
func (*TodoList) CreateList ¶
CreateList creates new List in the DB and links it to the given User
func (*TodoList) DeleteList ¶
DeleteList removes List from DB by ID
func (*TodoList) GetAllLists ¶
GetAllLists returns all lists from DB which belong to the given User
func (*TodoList) GetListByID ¶
GetListByID returns list by ID from DB which belongs to the given User
func (*TodoList) UpdateList ¶
UpdateList save changes of list to the DB