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

197
Visualizações
Firestore onSnapshot with "where" and "orderBy" not matching any documents

I am struggling to figure out why the following code produces the "doc.empty" console log. The screenshot shows what I see in Cloud Firestore's data console. My abbreviated code is below. In my example, I have the following variables:

dataset = '202203aam'
custnum = '19930'

enter image description here

firestoredb.collection('sold').doc(dataset).collection('sold').where('custnum', '==', parseInt(custnum)).orderBy('lot', 'asc').onSnapshot(function(doc){
    if (doc.empty){
        console.log('doc.empty');
    } else {
        doc.forEach(function(doc){
            //code here
        });
    }
});

Why would this not match my data?

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

0

The problem is here:

.where('custnum', '==', parseInt(custnum))

The screenshot shows that your custnum field has a string value, yet you are explicitly passing a numeric value in the condition. Strings and numeric values are never the same in the database, so the condition doesn't match the document you how.

To make the query work, make sure you pass the value as the same type that you've stored in the database.

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