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

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

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