// Children returns all Tags this Note is parent to. func (tag Tag) Children(c appengine.Context) ([]Tag, error) { children := make([]Tag, len(tag.ChildKeys)) err := cachestore.GetMulti(c, tag.ChildKeys, children) if err != nil { c.Errorf("getting tag children: %s", err) } return children, err }
// Notebooks returns all Notebooks that share this Tag. func (tag Tag) Notebooks(c appengine.Context) ([]Notebook, error) { notebooks := make([]Notebook, len(tag.NotebookKeys)) err := cachestore.GetMulti(c, tag.NotebookKeys, notebooks) if err != nil { c.Errorf("getting tag notebooks: %s", err) } return notebooks, err }
// Tags returns all tags used to sort this Notebook's notes func (notebook *Notebook) Tags(c appengine.Context) ([]Tag, error) { if len(notebook.tags) == 0 && len(notebook.NoteKeys) > 0 { notebook.tags = make([]Tag, len(notebook.TagKeys)) err := cachestore.GetMulti(c, notebook.TagKeys, notebook.tags) if err != nil { c.Errorf("getting notebook tags: %s", err) return notebook.tags, err } } return notebook.tags, nil }
// Notes returns all Notes that share this Tag. func (tag Tag) Notes(c appengine.Context) ([]Note, error) { notes := make([]Note, len(tag.NoteKeys)) err := cachestore.GetMulti(c, tag.NoteKeys, notes) if err != nil { c.Errorf("getting tag notes: %s", err) return notes, err } for i, note := range notes { note.ID = tag.NoteKeys[i].Encode() } return notes, nil }
// UntaggedNotes returns all untagged notes in this Notebook func (notebook *Notebook) UntaggedNotes(c appengine.Context) ([]Note, error) { if len(notebook.untaggedNotes) == 0 && len(notebook.UntaggedNoteKeys) > 0 { notebook.untaggedNotes = make([]Note, len(notebook.UntaggedNoteKeys)) err := cachestore.GetMulti(c, notebook.UntaggedNoteKeys, notebook.untaggedNotes) if err != nil { c.Errorf("getting notebook untagged notes: %s", err) return notebook.untaggedNotes, err } for i := 0; i < len(notebook.untaggedNotes); i++ { note := ¬ebook.untaggedNotes[i] note.ID = notebook.UntaggedNoteKeys[i].Encode() } } return notebook.untaggedNotes, nil }
// RelatedNotes returns the union of all Notes referred to by a set of Tags. func RelatedNotes(tags []Tag, c appengine.Context) ([]Note, error) { if len(tags) == 0 { return *new([]Note), nil } noteKeys := tags[0].NoteKeys for i := 1; i < len(tags); i++ { noteKeys = unionKeys(noteKeys, tags[i].NoteKeys) } notes, err := make([]Note, len(noteKeys)), *new(error) if len(noteKeys) > 0 { err = cachestore.GetMulti(c, noteKeys, notes) if err != nil { c.Errorf("getting related notes: %s", err) } } return notes, err }