Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to use orderByChild('status').equalTo('onTheWay') in Javascript in Web version 9 Module

I am trying to filter data from Firebase realtime database by child value
But i am not able to do as it was simple to do in web version 8
How can i achieve

i tried below

get(ref(database, 'Orders/'), orderByChild('status').equalTo('onTheWay')).then((snapshot) =>{
   //my code here
});

it gives me the following error

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

orderByChild(…).equalTo is not a function

enter image description here

>Solution :

You need to use query() function to build a query and pass each clause as a separate argument in it instead of chaining them. Try refactoring your code as shown below:

import { getDatabase, get, ref, query, orderByChild, equalTo } from "firebase/database";

const q = query(ref(db, 'Orders/'), orderByChild('status'), equalTo('onTheWay'));

get(q).then(snapshot => {
  console.log(q)
})
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading