repository

package
v0.0.0-...-61cd25c Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPostgresDB

func NewPostgresDB(cfg Config) (*sqlx.DB, error)

NewPostgresDB - коннект к БД

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 - репозитрий

func NewRepository

func NewRepository(db *sqlx.DB) *Repository

NewRepository - конструктор

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

type UserAction interface {
	Delete(userId int) error
}

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 - удаление пользователя

Jump to

Keyboard shortcuts

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