capecrawler
capecrawler

Reputation: 68193

What does ancestor mean in the google app engine datastore

Can anyone tell or define more what is "ancestor" and give an example on it and also what it is for? I just can't grasp what it really is.

Reference: http://code.google.com/appengine/docs/python/datastore/queryclass.html#Query_ancestor

Thanks.

Upvotes: 13

Views: 3405

Answers (1)

Alex Martelli
Alex Martelli

Reputation: 881555

Transactions in GAE only exist within ancestor-descendant groups. Equivalently, quoting the docs at the URL I just gave,

All datastore operations in a transaction must operate on entities in the same entity group

and an "entity group", per this page in the docs, are defined by:

When the application creates an entity, it can assign another entity as the parent of the new entity, using the parent argument in the Model constructor. Assigning a parent to a new entity puts the new entity in the same entity group as the parent entity.

"Ancestor" is just the transitive closure of "parent" -- i.e., given an entity, its ancestors are, its parent, its parent's parent, and so forth.

Upvotes: 22

Related Questions