开发者

Entities groups in transactions

In the context of "Keys and Entity Groups" article by google: http://code.google.com/appengine/docs/python/datastore/transactions.html

开发者_如何学编程1) "Only use entity groups when they are needed for transactions"

2) "Every entity belongs to an entity group, a set of one or more entities that can be manipulated in a single transaction."

It seems like entity groups exist only for the use of transactions, i.e. making one transaction possible between all entities in a group.

My question is then why are there parent-child relations between entities and not just a simple declaration of entities to be in a single group (that is defining A,B,C to be in the same group as opposed to defining relations between them "A (parent of) B, B (parent of C)").

What is the benefit from using parent-child relation model when the only purpose is for entities to be in the same group to make transaction possible?

Thanks

Joel


I think your question makes sense, but how would we define a group of entities without making the relationship explicit? Besides that, being able to know the parent of a model instance by the key path is useful sometimes. Furthermore, it makes these methods possible:

parent()

Returns a model instance for the parent entity of this instance, or None if this instance does not have a parent.

parent_key()

Returns the Key of the parent entity of this instance, or None if this instance does not have a parent.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜