Given the following problem:
A user has a set of chats and they have a set of messages.
I want to get chat messages sorted by date and also be able to paginate them.
At the moment my structure has the following form:
-chatCollection
-chatID
-properties
...
-userChatCollection
-userID
-chatID
-chatMessagesCollection
-chatID
-messageUID
-date:""
As a programmer who has used SQL I would say that the answer is simple: Through the user I can obtain the chats and through the chats I can obtain the ordered messages and limit them.
But as they say from firebase: Do not try to emulate a SQL query in firebase but try to store your data so that they will be easy to retrieve, I do not know if this structure is appropriate for my problem.
Could it be a solution to create a separate collection with only the order of the messages?