todo

package
v0.0.0-...-ba62778 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package todo holds the repository and the implementations for a TodoRepository.

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrListNotFound is returned when a list is not found.
	ErrListNotFound = errors.New("the list was not found")
	//ErrListAlreadyExist is returned when trying to add a list that already exists.
	ErrListAlreadyExist = errors.New("the list already exists")
)
View Source
var (
	// ErrItemAlreadyExists is returned when a todo item is added to a list it already exists in.
	ErrItemAlreadyExists = errors.New("item already exists")
)
View Source
var (
	// ErrMissingValues is returned when an item is created without a text.
	ErrMissingValues = errors.New("missing values")
)

Functions

This section is empty.

Types

type Item

type Item struct {
	ID        string
	Status    Status
	Text      string
	CreatedAt time.Time
	UpdatedAt time.Time
}

Item is an entity.

func NewItem

func NewItem(text string) (Item, error)

NewItem will create a new item. It will return error if it's an invalid item.

func (Item) Done

func (i Item) Done()

Done marks the status of an item as done.

type List

type List struct {
	ID        string
	Name      string
	Todos     []Item
	CreatedAt time.Time
	UpdatedAt time.Time
}

List is an aggregate.

func NewList

func NewList(n string) (*List, error)

NewList will create a new list of todos.

func (*List) AddItem

func (l *List) AddItem(item Item) error

AddItem adds item to the todo list.

func (*List) ListItems

func (l *List) ListItems() ([]Item, error)

ListItems lists all the items in the todo list.

func (*List) MarkItemDone

func (l *List) MarkItemDone(id string)

MarkItemDone marks item in the todo list as done.

func (*List) RemoveItem

func (l *List) RemoveItem(item Item)

RemoveItem removes item from the todo list.

type Status

type Status string

Status is a value object.

Jump to

Keyboard shortcuts

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