repository

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const CategoriesCollection = "categories"

Variables

This section is empty.

Functions

This section is empty.

Types

type CRepository

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

CRepository provides a mongo collection for database job.

func (*CRepository) DeleteAll

func (r *CRepository) DeleteAll() error

DeleteAll drops categories collection.

func (*CRepository) DeleteById

func (r *CRepository) DeleteById(id string) error

Delete deletes the url based on id.

func (*CRepository) GetAllURLsByCategory

func (r *CRepository) GetAllURLsByCategory(category string, count int) (url []*models.Category, err error)

GetAllURLsByCategory returns all urls based on category.

func (*CRepository) GetById

func (r *CRepository) GetById(id string) (url *models.Category, err error)

GetById returns the url based on id.

func (*CRepository) GetCategoryByURL

func (r *CRepository) GetCategoryByURL(url string) (category *models.Category, err error)

GetCategoryByURL returns the category based on url.

func (*CRepository) Save

func (r *CRepository) Save(url *models.Category) error

Save adds url to database.

func (*CRepository) Update

func (r *CRepository) Update(category *models.Category) error

Update updates the category.

type CategoriesRepository

type CategoriesRepository interface {
	Save(url *models.Category) error
	GetById(id string) (url *models.Category, err error)
	GetCategoryByURL(url string) (category *models.Category, err error)
	GetAllURLsByCategory(category string, count int) (url []*models.Category, err error)
	Update(category *models.Category) error
	DeleteById(id string) error
}

CategoriesRepository is the interface of the categorization backend.

func NewCategoriesRepository

func NewCategoriesRepository(conn db.Connection) CategoriesRepository

NewCategoriesRepository creates a new CategoriesRepository instance.

Jump to

Keyboard shortcuts

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