Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 776
capecrawler Avatar asked Mar 22 '10 06:03

capecrawler


People also ask

What is ancestor in Datastore?

ancestor (ancestor) Adds an ancestor filter to the query. The query will return only entities with the specified ancestor.

What is Datastore in Google App Engine?

Datastore is a NoSQL document database built for automatic scaling, high performance, and ease of application development. Datastore features include: Atomic transactions. Datastore can execute a set of operations where either all succeed, or none occur.

What is indexing in Datastore?

An index is defined on a list of properties of a given entity kind, with a corresponding order (ascending or descending) for each property. For use with ancestor queries, the index may also optionally include an entity's ancestors. An index table contains a column for every property named in the index's definition.

What is a Datastore entity?

Data objects in Datastore are known as entities. An entity has one or more named properties, each of which can have one or more values. Entities of the same kind do not need to have the same properties, and an entity's values for a given property do not all need to be of the same data type.


1 Answers

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.

like image 58
Alex Martelli Avatar answered Oct 13 '22 00:10

Alex Martelli