Hi there,
I'm building a chat interface and I'm having trouble retrieving the messages which are stored in firebase. I want to retrieve collection "messages" from a specific {chatId} and {userId}. I had no problem retrieving all the messages with a database query when had all the messages stored under "Chats" and only had to refer to the {userId}, but now that I've added another level with multiple chatIds, each with their own collection of messages, I can't seem to retrieve the messages. When I use the database query, the parent ref is the {userId}, but I don't know how to specify which {chatId} I want to retrieve. All the messages are then displayed in a list view, with the "sender" field determining how it gets displayed.
Below is my firestore database structure.
users (Collection)
βββ {userId} (Document)
βββ Chats (Sub Collection)
β βββ {chatId} (Document)
β βββ title (Field - String)
β βββ createdAt (Field - Date)
β βββ lastMessageAt (Field - Date)
β βββ messages (Sub Collection)
β βββ {messageId} (Document)
β βββ msg (field - string)
β βββ sender (field - string)
β βββ timestamp (field - date)
β βββ bookmark (field - boolean)
Any help is greatly appreciated.