Nested structs on GAE datastore using Go

后端 未结 2 885
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-18 08:28

I\'m trying to figure out how to get nested structs to work with GAE datastore using Go. I know the datastore doesn\'t specifically support nested structs. I need to find a

2条回答
  •  既然无缘
    2021-01-18 09:13

    Go's appengine datastore api provides the PropertyLoadSaver interface for this sort of thing: https://developers.google.com/appengine/docs/go/datastore/reference#PropertyLoadSaver

    You structure your struct however you want and then implement the Load and Save methods of that interface to populate it correctly. It means you write the serialization code yourself but it gives you full freedom in how you structure your data.

    This will allow you still filter over the fields and have a nested struct.

提交回复
热议问题