I have a list of users in firebase database and I want to make an array of all users whose isDonor value is true. How can I accomplish that?

1 Answer
Something like this should work:
let ref = firebase.database().ref("users");
ref.orderByChild("isDonor").equalTo(true).once("value").then((results) => {
results.forEach((snapshot) => {
console.log(snapshot.key, snapshot.val());
});
});
Also see the Firebase documentation on sorting and filtering data.
4 Comments
Aqsa Maan
can u please breifly explan this?
Frank van Puffelen
After reading the document I linked, what isn't clear about the code I shared?
Aqsa Maan
the issue is I can't render data. I have created an array and pushing each obect is it. so array look like this in console
[{"isDonor": true, "name": "Nadi", "photo": "https://gre", "uid": "2ZE"}, {"email": "mmaz", "isDonor": true, "name": "Mz", "photo": "https://gra", "uid": "Cb"}] but when i render it i get notthing on screen here is code {donorsData.map((v, i) => { return <Text key={i}>{v.name}</Text>; })}Aqsa Maan
sorry about that. forgot to do it.