Open Philio opened 2 months ago
Currently the solution I have is to save/load the key as an additional property:
func (s *BoxSpec) Load(ps []datastore.Property) error {
for _, p := range ps {
switch p.Name {
case "Key":
s.Key = p.Value.(*datastore.Key)
}
}
return nil
}
func (s *BoxSpec) Save() ([]datastore.Property, error) {
ps, err := datastore.SaveStruct(s)
if err != nil {
return ps, err
}
ps = append(ps, datastore.Property{
Name: "Key",
Value: s.Key,
})
return ps, nil
}
Client
Datastore
Environment
Linux
Go Environment
$ go version
$ go env
Code
I have a struct with 2 slices, they are interface types so although they save correctly they require a
PropertyLoadSaver
implementation to reconstruct them on loadExpected behavior
The key is returned by
datastore.SaveStruct(s)
(see debug screenshot below) so I would have expected it to be savedActual behavior
BoxSpec
is embedded in another entity, if I save without thePropertyLoadSaver
implementation the key gets saved:After adding
PropertyLoadSaver
implementation the key is returned bydatastore.SaveStruct(s)
but doesn't get saved in the database:Screenshots
Additional context
N/A