【发布时间】:2010-09-24 13:43:36
【问题描述】:
我需要在 in the Django database model 之类的查询中跨越 Google App Engine 实体关系。我将ListPropertys 用于一对多关系,如下所示:
class Foo(db.Model): bars = db.ListProperty(db.Key)
class Bar(db.Model): eggs = db.ListProperty(db.Key)
我想执行以下查询:
# Foo.filter('bars.eggs =', target_egg)
[foo
for egg in eggs if egg == target_egg
for eggs in bar.eggs
for bar in foo.bars
for foo in Foo.all()]
理解似乎效率极低。我真的很想像注释掉的部分那样执行查询,但看起来the GQL syntax 不允许针对属性的属性进行查询:
SELECT * FROM <kind>
[WHERE <condition> [AND <condition> ...]]
[ORDER BY <property> [ASC | DESC] [, <property> [ASC | DESC] ...]]
[LIMIT [<offset>,]<count>]
[OFFSET <offset>]
<condition> := <property> {< | <= | > | >= | = | != } <value>
<condition> := <property> IN <list>
<condition> := ANCESTOR IS <entity or key>
【问题讨论】:
标签: google-app-engine gql