storage

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2017 License: GPL-2.0, GPL-3.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteTask

func DeleteTask(task *task.Task) error

DeleteTask uses the current storage manager to delete a task

func GetAllEvents

func GetAllEvents() ([]*event.Event, error)

GetAllEvents returns all events saved in the storage manager

func GetAllTasks

func GetAllTasks() ([]*task.Task, error)

GetAllTasks returns all tasks saved in the storage manager

func Load

func Load() (int, int)

Load loads the saved tasks and registers them into the application

func Register

func Register(store Store)

Register sets a new Store as the current storage method

func SaveEvent

func SaveEvent(event *event.Event) error

SaveEvent saves an event in the storage manager

func SaveTask

func SaveTask(task *task.Task) error

SaveTask saves a new task in the storage manager

func UpdateTask

func UpdateTask(task *task.Task) error

UpdateTask uses the current storage manager to update a task

Types

type JSONFile

type JSONFile struct {
	Tasks  []*task.Task   `json:"tasks"`
	Events []*event.Event `json:"events"`
	// contains filtered or unexported fields
}

JSONFile is a store implementation that saves tasks consistently to a json file

func NewJSONFile

func NewJSONFile(filepath string) (j *JSONFile, err error)

NewJSONFile creates a new json file storage type

func (*JSONFile) DeleteTask

func (j *JSONFile) DeleteTask(t *task.Task) error

DeleteTask deletes a task from the json file

func (*JSONFile) GetAllEvents

func (j *JSONFile) GetAllEvents() (events []*event.Event, err error)

GetAllEvents returns all events loaded from the json file

func (*JSONFile) GetAllTasks

func (j *JSONFile) GetAllTasks() (tasks []*task.Task, err error)

GetAllTasks returns all tasks loaded from the json file

func (*JSONFile) SaveEvent

func (j *JSONFile) SaveEvent(event *event.Event) error

SaveEvent saves an event in the json file

func (*JSONFile) SaveTask

func (j *JSONFile) SaveTask(task *task.Task) error

SaveTask saves the task to the json file

func (*JSONFile) UpdateTask

func (j *JSONFile) UpdateTask(t *task.Task) error

UpdateTask updates as task and saves it to the json file

type Store

type Store interface {
	SaveTask(*task.Task) error
	DeleteTask(*task.Task) error
	UpdateTask(*task.Task) error
	GetAllTasks() ([]*task.Task, error)
	GetAllEvents() ([]*event.Event, error)
	SaveEvent(*event.Event) error
}

Store interface is an object which can store tasks for consistency and Could be a driver for a database, fileserver or any other storage mechanism

var Driver Store

Driver holds the active storage manager for the application

Jump to

Keyboard shortcuts

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