0

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? firebase database

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

can u please breifly explan this?
After reading the document I linked, what isn't clear about the code I shared?
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>; })}
sorry about that. forgot to do it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.