Note that there are some explanatory texts on larger screens.

plurals
  1. POPutting many PropertyList's into Google App Engine datastore (in Go) and loading them again with Query.GetAll
    text
    copied!<p>I am putting entities (as a <code>datastore.PropertyList</code>) into the datastore like this:</p> <pre><code>// save one var plist datastore.PropertyList = make(datastore.PropertyList, 3) plist = append(plist, datastore.Property { "name", "Mat", false, false }) plist = append(plist, datastore.Property { "age", "29", false, false }) plist = append(plist, datastore.Property { "location", "London", false, false }) key := datastore.NewIncompleteKey(context, "Record", nil) datastore.Put(context, key, &amp;plist) // save another one var plist datastore.PropertyList = make(datastore.PropertyList, 3) plist = append(plist, datastore.Property { "name", "Laurie", false, false }) plist = append(plist, datastore.Property { "age", "27", false, false }) plist = append(plist, datastore.Property { "location", "London", false, false }) key := datastore.NewIncompleteKey(context, "Record", nil) datastore.Put(context, key, &amp;plist) </code></pre> <p>That all works fine (although the code above is more like pseudo code for now). I am able to load them individually, and the <code>datastore.PropertyList</code> comes out with each field as its own <code>datastore.Property</code>.</p> <p>However, when I try to retrieve many of them using a <code>Query</code>, it fails:</p> <pre><code>query := datastore.NewQuery("Record") plists := make(datastore.PropertyList, 0, 10) keys, err := query.GetAll(context, &amp;plists) </code></pre> <p>I get the following error:</p> <pre><code>datastore: cannot load field "age" into a "datastore.Property": no such struct field </code></pre> <p>It seems that it doesn't complain about <code>Name</code> because that happens to be a valid property of <code>datastore.Property</code>, so how do I get it to load the items as intended, with each item in <code>plists</code> being a <code>datastore.PropertyList</code> instead of <code>datastore.Property</code>?</p>
 

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