views:

33

answers:

1

I would like to order entities by ancestor, GQL reference only mentions properties in ordering. Do I have to store a parent as a property to involve it in the ordering?

I trying to achieve something like this:

Foo.all().ancestor(bar).order('ancestor').order('-value').fetch(100)

EDIT:

I have something like this:

bar
 ├ spam
 │  ├ foo2 (value = 2)
 │  └ foo7
 └ egs
    ├ foo6
    └ foo5

And I'd like to get: [foo5, foo6, foo2, foo7]. I guess what I really want I to group them by ancestor, and then order them by value property.

+2  A: 

Ordering by key will sort first by ancestors, then by the id or name of the entity. If you want to sort by ancestor but not by id/name of the entity itself then yes, you'll need to include an explicit 'ancestor' SelfReferenceProperty to sort on.

Nick Johnson