【发布时间】:2016-10-07 14:04:37
【问题描述】:
我想在数据存储中存储分层实体。 子实体将有不同的种类,代表这样的东西:
type EntityA struct {
Id string
LeafA *EntityA
LeafB *EntityB
SomeValue string
}
type EntityB struct {
Id string
OtherValue string
}
我计划使用祖先,但似乎无法检索具有不同种类的共同祖先的孩子。
要检索整个父母,是否可以在不指定种类的情况下查询共同祖先的所有孩子?
或者是否有另一种可能解决这个问题?
【问题讨论】:
-
如果我正确理解了您的问题,您可能正在寻找无良的祖先查询 - cloud.google.com/appengine/docs/python/datastore/…
-
是的,完全正确。在 Python 中可以,但在 Go 中不行:stackoverflow.com/questions/14948440/… 我猜这是因为 Go 的静态类型。
-
我对 Go 不太了解,但在 AppEngine Go 文档中发现了这一点。似乎支持您的要求 - cloud.google.com/appengine/docs/go/datastore/…
标签: google-app-engine go google-cloud-datastore