Documentation
¶
Index ¶
- func CloseConnection(db *sql.DB)
- func OpenConnection() (*sql.DB, error)
- type CategoryRepository
- func (repo *CategoryRepository) CreateCategory(ctx context.Context, category *model.Category) (*model.Category, error)
- func (repo *CategoryRepository) DeleteCategory(ctx context.Context, id int) error
- func (repo *CategoryRepository) GetCategoryByID(ctx context.Context, id int) (*model.Category, error)
- func (repo *CategoryRepository) GetCategoryByName(ctx context.Context, name string) (*model.Category, error)
- func (repo *CategoryRepository) ListCategories(ctx context.Context) ([]*model.Category, error)
- func (repo *CategoryRepository) UpdateCategory(ctx context.Context, category *model.Category) error
- type Repositories
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseConnection ¶
CloseConnection fecha a conexão com o banco de dados.
func OpenConnection ¶
OpenConnection abre uma conexão com o banco de dados PostgreSQL.
Types ¶
type CategoryRepository ¶
type CategoryRepository struct {
// contains filtered or unexported fields
}
func NewCategoryRepository ¶
func NewCategoryRepository(db *sql.DB) *CategoryRepository
func (*CategoryRepository) CreateCategory ¶
func (repo *CategoryRepository) CreateCategory(ctx context.Context, category *model.Category) ( *model.Category, error)
CreateCategory insere uma nova categoria no banco de dados.
func (*CategoryRepository) DeleteCategory ¶
func (repo *CategoryRepository) DeleteCategory(ctx context.Context, id int) error
DeleteCategory exclui uma categoria do banco de dados.
func (*CategoryRepository) GetCategoryByID ¶
func (repo *CategoryRepository) GetCategoryByID(ctx context.Context, id int) (*model.Category, error)
GetCategoryByID obtém uma categoria pelo seu ID no banco de dados.
func (*CategoryRepository) GetCategoryByName ¶
func (repo *CategoryRepository) GetCategoryByName(ctx context.Context, name string) (*model.Category, error)
GetCategoryByName obtém uma categoria pelo seu name no banco de dados.
func (*CategoryRepository) ListCategories ¶
func (*CategoryRepository) UpdateCategory ¶
UpdateCategory atualiza uma categoria no banco de dados.
type Repositories ¶
type Repositories struct {
CategoryRepository category.CategoryRepository
}
func NewRepositories ¶
func NewRepositories(db *sql.DB) Repositories
Click to show internal directories.
Click to hide internal directories.