todo

package
v0.0.0-...-be1536b Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2016 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Overview

Package todo provides a type and several functions for interacting with todos backed by the Appengine Datastore. Todo entities are stored as descendants of the same parent, such that the lookups can be made strongly consistent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(c context.Context, k *datastore.Key) error

Delete removes the todo with the given key from the datastore. It returns an error if one occurred.

func DeleteCompleted

func DeleteCompleted(c context.Context) error

DeleteCompleted removes all finished todos from the datastore.

Types

type Todo

type Todo struct {
	Key   *datastore.Key `datastore:"-" json:"id"` // Unique identifier
	Title string         `json:"title"`            // Description
	Done  bool           `json:"completed"`        // Is this todo done?
}

func All

func All(c context.Context) ([]*Todo, error)

All returns a slice containing all todos in the datastore and an error, if one occurred. If there was no error, all todos will have their Key field initialized.

The underlying query is strongly consistent.

func Get

func Get(c context.Context, k *datastore.Key) (*Todo, error)

Get returns the todo with the given id and an error, if one occurred. If there was an error, the returned Todo should be considered unusable.

The underlying query is strongly consistent.

func NewTodo

func NewTodo(c context.Context, title string) (*Todo, error)

NewTodo creates a new todo given the given title, which can't be the empty string. It populates the Todo's Key field with an incomplete key.

func (*Todo) Save

func (t *Todo) Save(c context.Context) error

Save stores the todo entity in the datastore with the proper parent key. It returns an error if one was generated during storage. Otherwise, the todo's Key field is populated as a side effect.

Jump to

Keyboard shortcuts

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