Rob*_*Mao 3 google-app-engine join gql
说我有2种:
class Account(db.Model):
name = db.StringProperty()
create_time = db.DataTimeProperty()
last_login = db.DateTimeProperty()
last_update = db.DataTimeProperty()
class Relationship(db.Model)
owner = db.ReferenceProperty(Account)
target = db.ReferenceProperty(Account)
type = db.IntegerProperty()
Run Code Online (Sandbox Code Playgroud)
我想得到以下查询的等价:
SELECT target
FROM Relationship
WHERE owner = :key AND type = :type
ORDERBY target.last_login DESC
Run Code Online (Sandbox Code Playgroud)
怎么做?
参考:http://www.mail-archive.com/google-appengine@googlegroups.com/msg15878.html
数据存储区中的查询没有等效项.一些要点:
SELECT总是SELECT *(你选择一个完整的实体).因此,为了实现您的目标,您需要last_login存储Relationship或使用第3个模型作为该特定查询的索引.
| 归档时间: |
|
| 查看次数: |
443 次 |
| 最近记录: |