todos

package
v0.0.0-...-c6b0d7e Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: MIT Imports: 9 Imported by: 0

README

todos

Contains domain related entities and business logic implementations. The business functionality should be exported using Service interface that contains necessary functions to work with the entity.

Every domain/client should have it's own testing package (todostest) that can be used to mock the functionality of this package, usualy generated using external tools like mockery.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// TodoURLPrefix to be returned when encoding todo.
	TodoURLPrefix = os.Getenv("URL") + "todos/"
	// ErrTodoTitleBlank validation error.
	ErrTodoTitleBlank = errors.New("Title can't be blank")
)

Functions

This section is empty.

Types

type Filter

type Filter struct {
	Keyword   string
	Completed *bool
}

Filter for search.

type Service

type Service interface {
	Search(ctx context.Context, todos *[]Todo, filter Filter) error
	Create(ctx context.Context, todo *Todo) error
	Update(ctx context.Context, todo *Todo, changes rel.Changeset) error
	Delete(ctx context.Context, todo *Todo)
	Clear(ctx context.Context)
}

Service instance for todo's domain. Any operation done to any of object within this domain should use this service.

func New

func New(repository rel.Repository, scores scores.Service) Service

New Todos service.

type Todo

type Todo struct {
	ID        uint      `json:"id"`
	Title     string    `json:"title"`
	Order     int       `json:"order"`
	Completed bool      `json:"completed"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Todo respresent a record stored in todos table.

func (Todo) MarshalJSON

func (t Todo) MarshalJSON() ([]byte, error)

MarshalJSON implement custom marshaller to marshal url.

func (Todo) Validate

func (t Todo) Validate() error

Validate todo.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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