开发者

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

开发者 https://www.devze.com 2023-02-16 13:57 出处:网络
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.

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

精彩评论

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

关注公众号