开发者

Google App Engine database model

开发者 https://www.devze.com 2023-01-03 08:15 出处:网络
I need a simple application in GAE: I have users: public User { private @Id Long id; private String name;

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消