Say I have 2 kind:
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()
I want to get the equivalence of following query:
SELECT target
FROM Relationship
WHERE owner = :key AND type = :type
ORDERBY target.last_login DESC
How to do that?
reference: http://www.mail-archive.com/google-appengine@googlegroups.com/msg15878.html
There’s no equivalent for that query in datastore. Some points:
SELECTis alwaysSELECT *(you select a whole entity).So to achieve your goal, you need to have
last_loginstored inRelationship, or have a 3rd model to serve as index for that specific query.