Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The only types that are allowed for fields in the current version of the Go AppEngine SDK are <a href="http://code.google.com/appengine/docs/go/datastore/reference.html" rel="noreferrer">as follows</a>:</p> <ul> <li>signed integers (int, int8, int16, int32 and int64),</li> <li>bool,</li> <li>string,</li> <li>float32 and float64,</li> <li>any type whose underlying type is one of the above predeclared types,</li> <li>*Key,</li> <li>appengine.BlobKey,</li> <li>[]byte (up to 1 megabyte in length),</li> <li>slices of any of the above (up to 100 elements in length).</li> </ul> <p>Given that, there appear to be two ways to do this. One is to maintain a slice of keys to point to the Votes of a given Comment. However this is likely to run up against the 100 element limit for any reasonably popular comment.</p> <p>The other approach is to store a "pointer" to the comment in each vote struct like this:</p> <pre class="lang-go prettyprint-override"><code>type Vote struct { User string Score int CommentKey *datastore.Key } type Comment struct { Author string Content string Date datastore.Time } </code></pre> <p>Then when you go to query it you need to do it in two steps. First you get the Comment you're interested in (in this case just the first one that happens to be returned). Second, you query for all the votes that "point" to that comment:</p> <pre class="lang-go prettyprint-override"><code>q := datastore.NewQuery("Comment").Limit(1) comments := make([]Comment, 0, 1) var err os.Error var keys []*datastore.Key if keys, err = q.GetAll(c, &amp;comments); err != nil { // handle the error } comment := comments[0] vq := datastore.NewQuery("Vote").Filter("CommentKey=", keys[0]) votes := make([]Vote, 0, 10) if _, err := vq.GetAll(c, &amp;votes); err != nil { // handle the error } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload