开发者

How to order by ancestor/parent Google App Engine query?

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 gro开发者_如何转开发up them by ancestor, and then order them by value property.


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜