I need a simple application in GAE:
I have users:
public User {
private @Id Long id;
private String name;
}
and messages
private Message {
private @Id Long id;
private Key sender;
private Key reciever;
private Date sendDate;
}
The problem is: I need to fetch all messages sended and recieved by given user sorted by dandDate.
开发者_如何学运维I think I choose wrong model.
Can you advice me anything?
Thanks.
I would try something like:
SELECT * FROM Message WHERE sender = 'givenUserID' OR reciever = 'givenUserID' ORDER BY 'sendDate'
Just change sender and receiver to be of String type and in testing make sure you execute your query (That will automatically set them as indexes).
Take a look at Building Scalable, Complex Apps on App Engine (pdf), a fascinating talk given at Google I/O by Brett Slatkin. He addresses the problem of building a scalable messaging services.
精彩评论