repository

package
v0.0.0-...-8dcd180 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: Apache-2.0 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 - open connect and ping trying

Types

type AuthPostgres

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

AuthPostgres - repo

func NewAuthPostgres

func NewAuthPostgres(db *sqlx.DB) *AuthPostgres

NewAuthPostgres - constructor

func (*AuthPostgres) CreateUser

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

CreateUser - creating user

func (*AuthPostgres) GetUser

func (r *AuthPostgres) GetUser(username, password string) (models.User, error)

GetUser - getting user

type Author

type Author interface {
}

Author - author commands (not implemented, because is not required)

type AuthorPostgres

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

AuthorPostgres - repo

func NewAuthorPostgres

func NewAuthorPostgres(db *sqlx.DB) *AuthorPostgres

NewAuthorPostgres - constructor

type Authorization

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

Authorization - signup/signin

type Book

type Book interface {
	CreateBook(book models.Book) (int, error)
	GetAllBook() ([]models.Book, error)
	GetBookById(bookId int) (models.Book, error)
	DeleteBook(bookId int) error
	UpdateBook(bookId int, book models.Book) error
}

Book - book commands

type BookPostgres

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

BookPostgres - repo

func NewBookPostgres

func NewBookPostgres(db *sqlx.DB) *BookPostgres

NewBookPostgres - constructor

func (*BookPostgres) CreateBook

func (r *BookPostgres) CreateBook(book models.Book) (int, error)

CreateBook - book creating

func (*BookPostgres) DeleteBook

func (r *BookPostgres) DeleteBook(bookId int) error

DeleteBook - remove book

func (*BookPostgres) GetAllBook

func (r *BookPostgres) GetAllBook() ([]models.Book, error)

GetAllBook - getting all books

func (*BookPostgres) GetBookById

func (r *BookPostgres) GetBookById(bookId int) (models.Book, error)

GetBookById - getting book

func (*BookPostgres) UpdateBook

func (r *BookPostgres) UpdateBook(bookId int, book models.Book) error

UpdateBook - change book

type Config

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

Config - db

type Repository

type Repository struct {
	Authorization
	Book
	Author
}

Repository - repo

func NewRepository

func NewRepository(db *sqlx.DB) *Repository

NewRepository - constructor

Jump to

Keyboard shortcuts

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