开发者

Can I specify an Entity as a Datastore property to achieve join-like functionality?

For example, I have the entity Parent and the entity Child. Since the Datastore does not allow joins, I cannot specify parentKey as a property in Child. I mean, I can but that won't do me any good.

But if I want to retrieve Parent properties in queries to the Child, do I solve the problem by specifying the entire Parent entity as a property in Child? Is it proper to do so?

Entity parentEntity = new Entity(开发者_运维技巧"Parent");
// ... process parentEntity

Entity childEntity = new Entity("Child");
childEntity.setProperty("parentEntity", parentEntity);


An Entity cannot be stored as a property within another model (valid property types).

Instead, create one property on the child entity for each property you need a denormalized copy of in your child.


The current version of the datastore API doesn't support this, but Guido's NDB project supports nested entities.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜