category

package
v0.0.0-...-8495beb Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithID

func WithID(id CategoryID) option

Types

type Category

type Category struct {
	ID          CategoryID
	Name        string
	Description string
	Colour      string
	Sort        int
	Admin       bool
	Recent      []PostMeta
	PostCount   int
}

func FromModel

func FromModel(c *model.Category) *Category

type CategoryID

type CategoryID xid.ID

func (CategoryID) String

func (i CategoryID) String() string

type PostMeta

type PostMeta struct {
	Author string
	PostID xid.ID
	Slug   string
	Title  string
	Short  string
}

func PostMetaFromModel

func PostMetaFromModel(p *model.Post) *PostMeta

type Repository

type Repository interface {
	CreateCategory(ctx context.Context,
		name string,
		desc string,
		colour string,
		sort int,
		admin bool,
		opts ...option) (*Category, error)

	GetCategories(ctx context.Context, admin bool) ([]Category, error)
	UpdateCategory(ctx context.Context, id CategoryID, name, desc, colour *string, sort *int, admin *bool) (*Category, error)
	DeleteCategory(ctx context.Context, id CategoryID, moveto CategoryID) (*Category, error)
}

func New

func New(db *model.Client) Repository

Jump to

Keyboard shortcuts

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