Skip to content

Instantly share code, notes, and snippets.

@IndianGuru
Last active September 20, 2015 07:26
Show Gist options
  • Select an option

  • Save IndianGuru/5dcff97d5b176e023405 to your computer and use it in GitHub Desktop.

Select an option

Save IndianGuru/5dcff97d5b176e023405 to your computer and use it in GitHub Desktop.
The List service
// List returns a list of all the existing quotes.
func (QuotesAPI) List(c context.Context) (*Quotes, error) {
quotes := []Quote{}
// If we omitted the .Ancestor from this query there would be
// a slight chance that Quote that had just been written would not
// show up in a query.
keys, err := datastore.NewQuery("Quote").Ancestor(quoteKey(c)).GetAll(c, &quotes)
if err != nil {
return nil, err
}
for i, k := range keys {
quotes[i].UID = k
}
return &Quotes{quotes}, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment