私は次のモデルを持っています:
class Conversation:
questionId = db.IntegerProperty(required=True)
count = db.IntegerProperty(required=True)
message = db.StringProperty(required=True)
会話は、元の質問 ID、メッセージ数、およびメッセージで構成されます。したがって、データの例は次のようになります。
- questionId: 2; count: 0; message: How are you?
- questionId: 2; count: 1; message: I'm fine thanks, how are your kids?
- questionId: 2; count: 2; message: They're great, growing to fast!
- questionId: 3; count: 0; message: John, your late!
- questionId: 3; count: 1; message: I know, I'm so sorry!
ここでの私の質問は、各質問 ID ごとに最新の (最大の) カウントを取得するためにクエリを実行するにはどうすればよいですか? 上記の例から、次のように返されます。
- questionId: 2; count: 2; message: They're great, growing to fast!
- questionId: 3; count: 1; message: I know, I'm so sorry!
残念ながら、データは例のように並べ替えられて保存されないことに注意してください。したがって、すべての行が順不同であると想像してください。テーブル数もすごい!どうもありがとう!