Reputation: 18982
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.
Upvotes: 2
Views: 879
Reputation: 101139
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.
Upvotes: 4