Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
Firebase collection group limit for each collection

I have a Firestore problem querying data. I have a collection called conversations. Within each conversation document, there is a collection called messages. Each message has a field time, which is a timestamp.

How do I query a collection group such that I get the most recent message in each conversation?

I am using the SDK for the web, version 9.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

That doesn't seem to be possible with a collection group query. Using .orderBy() will sort all document in messages sub-collection. You might have to get list of all user conversations and then fetch last message from each conversation individually.

Do note that using .collectionGroup('messages') will look for documents in all collections named as messages including other users. So make sure you have some filters there.

You can store last message in conversation document itself but that'll incur and additional write every time a new message is added.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!