Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

172
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda