repository

package
v0.0.0-...-15fe6cf Latest Latest
Warning

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

Go to latest
Published: Feb 15, 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(config Config) (*sqlx.DB, error)

NewPostgresDB creates a new instance of Postgres DB

Types

type AuthPostgres

type AuthPostgres struct {
	// contains filtered or unexported fields
}

func NewAuthPostgres

func NewAuthPostgres(db *sqlx.DB) *AuthPostgres

NewAuthPostgres creates a new AuthPostgres

func (AuthPostgres) CreateUser

func (r AuthPostgres) CreateUser(user todo.User) (int, error)

CreateUser saves a new user in Post

func (AuthPostgres) GetUser

func (r AuthPostgres) GetUser(username string, passwordHash string) (todo.User, error)

GetUser finds a user in DB according to the username and hashed password specified.

type Authorization

type Authorization interface {
	CreateUser(user todo.User) (int, error)
	GetUser(username string, passwordHash string) (todo.User, error)
}

type Config

type Config struct {
	Host     string
	Port     string
	Username string
	Password string
	DBName   string
	SSLMode  string
}

type Repository

type Repository struct {
	Authorization
	TodoList
	TodoItem
}

func New

func New(db *sqlx.DB) *Repository

New creates a new 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
}

type TodoItemPostgres

type TodoItemPostgres struct {
	// contains filtered or unexported fields
}

func NewTodoItemPostgres

func NewTodoItemPostgres(db *sqlx.DB) *TodoItemPostgres

func (*TodoItemPostgres) Create

func (r *TodoItemPostgres) Create(listId int, item todo.TodoItem) (int, error)

func (*TodoItemPostgres) Delete

func (r *TodoItemPostgres) Delete(userId, itemId int) error

func (*TodoItemPostgres) GetAll

func (r *TodoItemPostgres) GetAll(userId, listId int) ([]todo.TodoItem, error)

func (*TodoItemPostgres) GetById

func (r *TodoItemPostgres) GetById(userId, itemId int) (todo.TodoItem, error)

func (*TodoItemPostgres) Update

func (r *TodoItemPostgres) Update(userId, itemId int, input todo.UpdateItemInput) error

type TodoList

type TodoList interface {
	Create(userId int, list todo.TodoList) (int, error)
	FindAll(userId int) ([]todo.TodoList, error)
	FindById(userId, id int) (todo.TodoList, error)
	Delete(userId, id int) error
	Update(userId, id int, updateListRequest todo.UpdateTodoListRequest) error
}

type TodoListPostgres

type TodoListPostgres struct {
	// contains filtered or unexported fields
}

func NewTodoListPostgres

func NewTodoListPostgres(db *sqlx.DB) *TodoListPostgres

func (TodoListPostgres) Create

func (r TodoListPostgres) Create(userId int, list todo.TodoList) (int, error)

func (TodoListPostgres) Delete

func (r TodoListPostgres) Delete(userId, listId int) error

Delete deletes Todolist for specified user

func (TodoListPostgres) FindAll

func (r TodoListPostgres) FindAll(userId int) ([]todo.TodoList, error)

FindAll finds all TodoList for specified userId

func (TodoListPostgres) FindById

func (r TodoListPostgres) FindById(userId, id int) (todo.TodoList, error)

FindById finds TodoList by specified listId

func (TodoListPostgres) Update

func (r TodoListPostgres) Update(userId, listId int, updateListRequest todo.UpdateTodoListRequest) error

Update updates the specified TodoList

Jump to

Keyboard shortcuts

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