views:

81

answers:

2

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.

A: 

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).

Romain Hippeau
+2  A: 

I would try something like:

SELECT * FROM Message WHERE sender = 'givenUserID' OR reciever = 'givenUserID' ORDER BY 'sendDate'
sethrq
If I not misstaken, it is not available to use "OR" in BigTable queries.
R.Gregory