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
orderByChild(...).equalTo is not a function
CodePudding user response:
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)
})