私はこのような単純な1対多の構造を持っている:私は彼のメールでからユーザーをフェッチReferencePropertyを使用すると、日付順に注文する方法を教えてください。
class User(db.Model):
userEmail = db.StringProperty()
class Comment(db.Model):
user = db.ReferenceProperty(User, collection_name="comments")
comment = db.StringProperty()
date = db.DateTimeProperty()
を:
q = User.all() # prepare User table for querying
q.filter("userEmail =", "[email protected]") # apply filter, email lookup
results = q.fetch(1) # execute the query, apply limit 1
the_user = results[0] # the results is a list of objects, grab the first one
this_users_comments = the_user.comments # get the user's comments
は、どのように私は、ユーザーの日付によって、コメント、および制限を注文することができますそれは10のコメントに?
が、私は同様のものを使用: '記事=ソート済み(記事、キー=ラムダx:x.modified、逆= True) ' –