Documentation
¶
Index ¶
- func NewPostgresDB(cfg Config) (*sqlx.DB, error)
- type AuthPostgres
- type Authorization
- type Config
- type Repository
- type TodoItem
- type TodoItemPostgres
- func (r *TodoItemPostgres) Create(listId int, item todo.TodoItem) (int, error)
- func (r *TodoItemPostgres) Delete(userId, itemId int) error
- func (r *TodoItemPostgres) GetAll(userId, listId int) ([]todo.TodoItem, error)
- func (r *TodoItemPostgres) GetAllCompletedItems(userId int) ([]todo.TodoItem, error)
- func (r *TodoItemPostgres) GetById(userId, itemId int) (todo.TodoItem, error)
- func (r *TodoItemPostgres) Update(userId, itemId int, input todo.UpdateItemInput) error
- type TodoList
- type TodoListPostgres
- func (r *TodoListPostgres) Create(userId int, list todo.TodoList) (int, error)
- func (r *TodoListPostgres) Delete(userId, listId int) error
- func (r *TodoListPostgres) GetAll(userId int) ([]todo.TodoList, error)
- func (r *TodoListPostgres) GetById(userId, listId int) (todo.TodoList, error)
- func (r *TodoListPostgres) Update(userId, listId int, input todo.UpdateListInput) error
- type UserAction
- type UserPostgres
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthPostgres ¶
type AuthPostgres struct {
// contains filtered or unexported fields
}
AuthPostgres - репозиторий
func NewAuthPostgres ¶
func NewAuthPostgres(db *sqlx.DB) *AuthPostgres
NewAuthPostgres - конструктор объекта репозитория
func (*AuthPostgres) CreateUser ¶
func (r *AuthPostgres) CreateUser(user todo.User) (int, error)
CreateUser - создание пользователя
func (*AuthPostgres) GetUser ¶
func (r *AuthPostgres) GetUser(username, password string) (todo.User, error)
GetUser - получение пользователя из БД
type Authorization ¶
type Authorization interface { CreateUser(user todo.User) (int, error) GetUser(username, password string) (todo.User, error) }
Authorization - интерфейс для регистрации/авторизации
type Config ¶
type Config struct { Driver string Host string Port string Username string Password string DBName string SSLMode string }
Config - конфиг БД
type Repository ¶
type Repository struct { Authorization TodoList TodoItem UserAction }
Repository - репозитрий
type TodoItem ¶
type TodoItem interface { Create(listId int, item todo.TodoItem) (int, error) GetAll(userId, listId int) ([]todo.TodoItem, error) GetById(userId, itemId int) (todo.TodoItem, error) Delete(userId, itemId int) error Update(userId, itemId int, input todo.UpdateItemInput) error GetAllCompletedItems(userId int) ([]todo.TodoItem, error) }
TodoItem - интейрфейс для работы с элементами списка задач
type TodoItemPostgres ¶
type TodoItemPostgres struct {
// contains filtered or unexported fields
}
TodoItemPostgres - объект работы с таблицей ЭЛЕМЕТОВ списков задач
func NewTodoItemPostgres ¶
func NewTodoItemPostgres(db *sqlx.DB) *TodoItemPostgres
NewTodoItemPostgres - конструктор
func (*TodoItemPostgres) Create ¶
func (r *TodoItemPostgres) Create(listId int, item todo.TodoItem) (int, error)
Create - создание ЭЛЕМЕТОВ списка задач
func (*TodoItemPostgres) Delete ¶
func (r *TodoItemPostgres) Delete(userId, itemId int) error
Delete - удаление ЭЛЕМЕНТА
func (*TodoItemPostgres) GetAll ¶
func (r *TodoItemPostgres) GetAll(userId, listId int) ([]todo.TodoItem, error)
GetAll - получение всех ЭЛЕМЕТОВ выбранного списка
func (*TodoItemPostgres) GetAllCompletedItems ¶
func (r *TodoItemPostgres) GetAllCompletedItems(userId int) ([]todo.TodoItem, error)
GetAllCompletedItems - получение всех выполненных ЭЛЕМЕТОВ
func (*TodoItemPostgres) GetById ¶
func (r *TodoItemPostgres) GetById(userId, itemId int) (todo.TodoItem, error)
GetById - получение ЭЛЕМЕНТА
func (*TodoItemPostgres) Update ¶
func (r *TodoItemPostgres) Update(userId, itemId int, input todo.UpdateItemInput) error
Update - обновление ЭЛЕМЕНТА
type TodoList ¶
type TodoList interface { Create(userId int, list todo.TodoList) (int, error) GetAll(userId int) ([]todo.TodoList, error) GetById(userId, listId int) (todo.TodoList, error) Delete(userId, listId int) error Update(userId, listId int, input todo.UpdateListInput) error }
TodoList - интерфейст для работы со списками задач
type TodoListPostgres ¶
type TodoListPostgres struct {
// contains filtered or unexported fields
}
TodoListPostgres - объект работы с таблицей СПИСКОВ задач
func NewTodoListPostgres ¶
func NewTodoListPostgres(db *sqlx.DB) *TodoListPostgres
NewTodoListPostgres - контруктор
func (*TodoListPostgres) Create ¶
func (r *TodoListPostgres) Create(userId int, list todo.TodoList) (int, error)
Create - создание СПИСКА
func (*TodoListPostgres) Delete ¶
func (r *TodoListPostgres) Delete(userId, listId int) error
Delete - удаление СПИСКА
func (*TodoListPostgres) GetAll ¶
func (r *TodoListPostgres) GetAll(userId int) ([]todo.TodoList, error)
GetAll - получение всех СПИСКОВ пользователя
func (*TodoListPostgres) GetById ¶
func (r *TodoListPostgres) GetById(userId, listId int) (todo.TodoList, error)
GetById - получение СПИСКА
func (*TodoListPostgres) Update ¶
func (r *TodoListPostgres) Update(userId, listId int, input todo.UpdateListInput) error
Update - удаление СПИСКА
type UserAction ¶
UserAction - интерфейс для удаления пользователей
type UserPostgres ¶
type UserPostgres struct {
// contains filtered or unexported fields
}
UserPostgres - репозиторий
func NewUserPostgres ¶
func NewUserPostgres(db *sqlx.DB) *UserPostgres
NewUserPostgres - конструктор объекта репозитория
func (*UserPostgres) Delete ¶
func (r *UserPostgres) Delete(userId int) error
DeleteUser - удаление пользователя