I put objects (like datastore.PropertyList ) in the data store as follows:
// 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, &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, &plist)
Everything works fine (although the code above is more like pseudo code). I can load them individually, and datastore.PropertyList comes out with each field as its own datastore.Property .
However, when I try to extract many of them using Query , it fails:
query := datastore.NewQuery("Record") plists := make(datastore.PropertyList, 0, 10) keys, err := query.GetAll(context, &plists)
I get the following error:
datastore: cannot load field "age" into a "datastore.Property": no such struct field
It seems that he does not complain about Name , because this is a valid property of datastore.Property , so how do I load it as expected, with each element in plists being a datastore.PropertyList instead of datastore.Property ?