todo

package
v0.0.0-...-53ae9e6 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetStorage

func SetStorage(st Storage)

SetStorage - setter

Types

type BulkOp

type BulkOp struct {
	Op    DbOp
	Items []*TaskItem
}

BulkOp - represents batch operation on data storage

type DbOp

type DbOp string

DbOp - opcode for bulk operations

var Create DbOp = "create"

Create -

var Delete DbOp = "delete"

Delete -

var Update DbOp = "update"

Update -

type JSONStorage

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

JSONStorage -

func (*JSONStorage) Add

func (js *JSONStorage) Add(item *TaskItem) error

Add -

func (*JSONStorage) Bulk

func (js *JSONStorage) Bulk(op BulkOp) error

Bulk -

func (*JSONStorage) Close

func (js *JSONStorage) Close() error

Close -

func (*JSONStorage) Init

func (js *JSONStorage) Init() error

Init -

func (*JSONStorage) Name

func (js *JSONStorage) Name() string

Name -

func (*JSONStorage) Remove

func (js *JSONStorage) Remove(id int) error

Remove -

func (*JSONStorage) Retrieve

func (js *JSONStorage) Retrieve(id int) (*TaskItem, error)

Retrieve -

func (*JSONStorage) RetrieveAll

func (js *JSONStorage) RetrieveAll(offset, limit int) ([]*TaskItem, error)

RetrieveAll -

func (*JSONStorage) Update

func (js *JSONStorage) Update(item *TaskItem) error

Update -

type Storage

type Storage interface {
	Name() string
	Init() error
	Add(item *TaskItem) error
	Remove(id int) error
	Update(item *TaskItem) error
	Retrieve(id int) (*TaskItem, error)
	Bulk(op BulkOp) error
	RetrieveAll(offset, limit int) ([]*TaskItem, error)
}

Storage - represents a storage backend for the task list

func GetStorage

func GetStorage() Storage

GetStorage - getter

type TaskItem

type TaskItem struct {
	ID          int       `json:"id" db:"id"`
	Heading     string    `json:"heading, required" db:"heading"`
	Description string    `json:"description" db:"description"`
	Status      string    `json:"status" db:"status"`
	Created     time.Time `json:"created" db:"created"`
	Deadline    time.Time `json:"deadline" db:"deadline"`
	Modified    time.Time `json:"modified" db:"modified"`
}

TaskItem - represents a todo item

func NewTaskItem

func NewTaskItem(heading, description string, deadline time.Time) *TaskItem

NewTaskItem -

func (*TaskItem) String

func (ti *TaskItem) String() string

type TaskList

type TaskList struct {
	Tasks  []*TaskItem `json:"tasks"`
	NextID int         `json:"nextID"`
}

TaskList -

func Load

func Load() (*TaskList, error)

Load -

func NewTaskList

func NewTaskList() *TaskList

NewTaskList -

func (*TaskList) Add

func (tl *TaskList) Add(items ...*TaskItem)

Add -

func (*TaskList) Iterate

func (tl *TaskList) Iterate(operation func(*TaskItem))

Iterate -

func (*TaskList) Remove

func (tl *TaskList) Remove(id int)

Remove -

Jump to

Keyboard shortcuts

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