开发者

in gql, how do i sort by a field in another class linked by referenceproperty?

开发者 https://www.devze.com 2023-01-13 07:56 出处:网络
for example, 2 classes in a 1-to-many relationship: class owner(db.model): name = db.StringProperty() class cat(db.model):

for example, 2 classes in a 1-to-many relationship:

class owner(db.model):
    name = db.StringProperty()

class cat(db.model):
    name开发者_StackOverflow中文版 = db.StringProperty()
    owner = db.ReferenceProperty(owner)

so how do i produce a list of cats ordered by owner.name (then optionally by cat.name)?

i tried "SELECT * FROM cat ORDER BY owner.name" but got Parse Error: Expected no additional symbols at symbol .name

Thanks


You can't; this would require a join, which the datastore doesn't support. If you need to sort like this, denormalize your data and include the owner name in the cat model.

0

精彩评论

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

关注公众号