Documentation ¶
Index ¶
- func CategoriesToStrSlice(categories Categories) []string
- type Categories
- type Category
- type Service
- func (cs *Service) Create(ctx context.Context, tx *gorm.DB, newCategory dtos.CreateCategory) (*Category, *ign.ErrMsg)
- func (cs *Service) Delete(ctx context.Context, tx *gorm.DB, categorySlug string) (*Category, *ign.ErrMsg)
- func (cs *Service) List(tx *gorm.DB) (*Categories, *ign.ErrMsg)
- func (cs *Service) Update(ctx context.Context, tx *gorm.DB, categorySlug string, cat dtos.UpdateCategory) (*Category, *ign.ErrMsg)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CategoriesToStrSlice ¶
func CategoriesToStrSlice(categories Categories) []string
CategoriesToStrSlice returns a slice of category names by the given categories slice
Types ¶
type Categories ¶
type Categories []Category
Categories is an array of Category
swagger:model
func ByNames ¶
func ByNames(tx *gorm.DB, names []string) (*Categories, error)
ByNames returns a slice of Categories from the given slice of names.
func StrSliceToCategories ¶
func StrSliceToCategories(tx *gorm.DB, sl []string) (*Categories, error)
StrSliceToCategories returns a slice of categories by the given category names
type Category ¶
type Category struct { gorm.Model // Name is the name of the category Name *string `gorm:"not null;unique" json:"name"` // Slug is the human-friendly URL path to the category Slug *string `gorm:"not null;unique" json:"slug"` // ParentID is an optional parent ID. ParentID *uint `json:"parent_id,omitempty"` }
Category is a type of label used to group resources, such as models and worlds, together. A category consists of a name, ID, and parentID. The parentID field should refer to a parent category, and supports a hierarchy of categories.
swagger:model
type Service ¶
type Service struct{}
Service is a structure used in the REST API.
func (*Service) Create ¶
func (cs *Service) Create(ctx context.Context, tx *gorm.DB, newCategory dtos.CreateCategory) (*Category, *ign.ErrMsg)
Create creates a new Category in DB using the data from the given CreateCategory dto.
func (*Service) Delete ¶
func (cs *Service) Delete(ctx context.Context, tx *gorm.DB, categorySlug string) (*Category, *ign.ErrMsg)
Delete deletes a category by the given slug.