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

162
Visualizações
Firestore sort by value

I'm trying to create a filter for my application It will filter by the datas' category, but I also want to sort them by its rating, higher rating will be on the top. I wrote the following code, but the orderby() function having issue.

        const snapshot = await firebase.firestore().collection('Locations').where(
            "category", "==", type).orderBy("rating").get();
        
        if (snapshot.empty){
            console.log('No matching documents');
            return;
        }
        
        snapshot.forEach(doc=> {
            locList.push(doc.data());
        })

and here is my firestore data look like firestore data

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

To sort values from largest rating to smallest rating, specify the ordering as descending. Change the orderBy function to:

.orderBy('rating', 'desc')

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