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

195
Views
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 answers
Answer question

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 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!