1 year ago

#389292

test-img

User123123

Sorting an docs by comparing the docs in a subcollection with the most recent date in firestore

I have a firestore structure like this:

chats > chat docs with unique IDs

Each chat doc contains these values:

id, members and more info on the chat like nicknames etc.

In addition, there is a subcollection containing all the messages,

the messages also each have their own doc id, a date, and message.

How can I sort the chat docs when fetching them from firebase based on the last message thst was sent given each message has a timestamp associated with it.

Is it possible to solve this without modifying the firestore structure?

javascript

firebase

google-cloud-firestore

0 Answers

Your Answer

Accepted video resources