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

149
Views
orderByChild is not a function

i am trying to fetch filtered data from my firebase database in reactjs web application.i do it as follow, but it gives this error that..orderByChild is not a functionwhat's going on, i cants understand.

import fb from '../../firebase';
const DB =fb.firestore();
const restro_list = DB.collection('restros');
const[restros, Setrestros] = useState([]);

useEffect(()=>{
    const unsubrestro = restro_list.orderByChild('MealType').on('value', snapshot => {
       snapshot.forEach(docu => {
          const data = docu.docs.forEach(doc => ({
             ...doc.val(),
             id: doc.id,
           }));
           Setrestros(data);
        });
   });
   return unsubrestro;
 },[]);

but this always give me error.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The orderByChild() is a function in Firebase Realtime Database SDK but you are using Firestore where you should use orderBy() as shown below:

const unsubrestro = restro_list.orderBy("MealType").onSnapshot((snapshot) => {
  const data = snapshot.docs.map((d) => ({ id: d.id, ...d.data() }))
  Setrestros(data);
})
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!