Hey Martin :)
Some answers:
Q1. "are there any docs on how the structs should look exactly?"
The struct format is explained in the GetPLS docstring (which I realize totally un-findable :)).
https://godoc.org/github.com/luci/gae/service/datastore#GetPLS . I filed a bug to make this documentation more prominent (
https://github.com/luci/gae/issues/18). I would also point out that the datastore.Interface also contains a 'Raw' version that deals solely with []*datastore.Key and []datastore.PropertyMap, which is occasionally more convenient than the normal fancy interface. TL;DR for this question is that struct fields can be tagged like:
type MyStruct struct {
// kind is automatically derived from the struct name, but can be overridden
Kind string `gae:"$kind"` // allows a dynamically settable kind; OR
Kind string `gae:"$kind,defaultName` // default assigned kind name if Kind == ""
ID int64 `gae:"$id"` // int id; OR
ID string `gae:"$id"` // string id
// ID can have defaults too
Parent *datastore.Key `gae:"$parent"` // what you think :)
}
type MyFancyID struct {
Name string
Category string
}
var _ datastore.PropertyConverter = (*MyFancyID)(nil)
func (i *MyFancyID) ToProperty() (datastore.Property, error) {
return datastore.MkProperty(fmt.Sprintf("%s|%s", i.Name, i.Category)), nil
}
func (i *MyFancyID) FromProperty(p datastore.Property) error {
// something like:
// i.Name, i.Category = strings.SplitN(p.Value().(string), "|", 2)
// but in the super-verbose go way that handles errors and such :)
}
type MyStruct struct {
MyFancyID `gae:"$id"` // Name and Category will be used/filled when writing/reading this from the datastore
}
Q2. "best way to handle APIs that have no equivalent"
Q3. Migration docs?
Unfortunately no :(. We haven't had the opportunity to sit down and think about this process. I added a bug to doc this too :)
Thanks for taking a look!
R