I'm using GreenDAO in my project.
I have a chats table which contains all the messages.
I want to group by the chat_id
and order the messages in descending order by the timestamp of the message.
so what I'm trying to get is a list that contains the most recent message of each chat the user has.
this is the code I'm using:
Chats.queryBuilder()
.orderDesc(ChatsDAO.Properties.TimeStamp)
.where(ChatsDAO.Properties.UserId.eq(user_id))
.where(new WhereCondition.StringCondition("1 GROUP BY chat_id"))
.list();
but still, the code above gives me a list which contains the first message of each chat, instead of the recent message.
is there any way to make a raw query using greenDAO and select what I want?