models

package
v0.0.0-...-f037d2d Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Task

type Task struct {
	Id    string    `json:"id"`
	Title string    `json:"title"`
	Body  string    `json:"body"`
	Date  time.Time `json:"date"`
}

Json syntax https://golang.org/pkg/encoding/json/#Marshal

func NewTask

func NewTask(title string, body string) (Task, error)

NewTask creates a new task given a title, that can't be empty.

func (Task) Equal

func (t Task) Equal(task Task) bool

Check if tasks equal, Id is NOT checked.

type Tasks

type Tasks map[string]*Task

String to be able to JSON the map.

func NewTaskManager

func NewTaskManager() Tasks

NewTaskManager returns an empty Tasks.

func (Tasks) Add

func (t Tasks) Add(task Task) error

Add a task with existing Id.

func (Tasks) All

func (t Tasks) All() []*Task

All returns the list of all the Tasks.

func (Tasks) Delete

func (t Tasks) Delete(Id string)

Delete Task by Id.

func (Tasks) Find

func (t Tasks) Find(Id string) (*Task, bool)

Find returns the Task with the given id in the TaskManager.

func (Tasks) Save

func (t Tasks) Save(task Task) (string, error)

Save saves the given Task in the TaskManager.

func (Tasks) Update

func (t Tasks) Update(uid string, task Task) (*Task, error)

Update task.

Jump to

Keyboard shortcuts

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