repository

package
v0.0.0-...-263bac0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: MIT Imports: 6 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)

Types

type AuthPostgres

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

func NewAuthPostgres

func NewAuthPostgres(db *sqlx.DB) *AuthPostgres

func (*AuthPostgres) CreateUser

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

func (*AuthPostgres) GetUser

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

type Authorization

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

type Comment

type Comment interface {
	Create(idUser int, comment common.Comment) (int, error)
	GetAll(idUser int) ([]common.Comment, error)
	GetById(idUser, commentId int) (common.Comment, error)
	Update(idUser, commentId int, input common.UpdateCommentInput) error
	Delete(idUser, commentId int) error
}

type CommentPostgres

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

func NewCommentPostgres

func NewCommentPostgres(db *sqlx.DB) *CommentPostgres

func (*CommentPostgres) Create

func (r *CommentPostgres) Create(idUser int, comment common.Comment) (int, error)

func (*CommentPostgres) Delete

func (r *CommentPostgres) Delete(idUser, commentId int) error

func (*CommentPostgres) GetAll

func (r *CommentPostgres) GetAll(idUser int) ([]common.Comment, error)

func (*CommentPostgres) GetById

func (r *CommentPostgres) GetById(idUser, commentId int) (common.Comment, error)

func (*CommentPostgres) Update

func (r *CommentPostgres) Update(idUser, commentId int, input common.UpdateCommentInput) error

type Config

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

type Repository

type Repository struct {
	Authorization
	Comment
	User
}

func NewRepository

func NewRepository(db *sqlx.DB) *Repository

type User

type User interface {
	Create(user common.User) (int, error)
	GetById(idUser int) (common.User, error)
	Update(id int, input common.UpdateUserInput) error
	Delete(idUser int) error
}

type UserPostgres

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

func NewUserPostgres

func NewUserPostgres(db *sqlx.DB) *UserPostgres

func (*UserPostgres) Create

func (r *UserPostgres) Create(user common.User) (int, error)

func (*UserPostgres) Delete

func (r *UserPostgres) Delete(id int) error

func (*UserPostgres) GetById

func (r *UserPostgres) GetById(id int) (common.User, error)

func (*UserPostgres) Update

func (r *UserPostgres) Update(id int, input common.UpdateUserInput) error

Jump to

Keyboard shortcuts

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