Last active
September 20, 2015 07:26
-
-
Save IndianGuru/5dcff97d5b176e023405 to your computer and use it in GitHub Desktop.
The List service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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, "es) | |
| 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