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

105
Views
Get children specific value and update when there is a change Firebase v9

I have this database. I would like to get only the values highlighted red. When there is a new child with same value profile_picture:, i would like to update the list as well.

enter image description here

I manage to get all the values but i still can't figure out how to get only profile_picture: value from every child.

    // Initialize Firebase
    const app = initializeApp(firebaseConfig);
    const db = getDatabase();
    const email = ref(db, 'users/');
    onValue(email, (snapshot) => {
        console.log(snapshot.val())
    })

OUTPUT

[
null,
{
    "email": "Test_1_Email",
    "profile_picture": "Test_1_URL",
    "username": "Test_1"
},
{
    "email": "Test_2_Email",
    "profile_picture": "Test_2_URL",
    "username": "Test_2"
}
]
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

That cannot be done by a single listener. ref(db, 'users/') will return the whole /users node. If you just want to listen for profile_picture then you'll have to add a listener for every user's profile_picture like this:

const userIds = ["u1", "u2"]

userIds.forEach(user => {
  const email = ref(db, 'users/' + user);
  onValue(email, (snapshot) => {
    console.log(snapshot.val())
  })
})

I had hard-coded the UIDs here for example but you'll need to know the user IDs beforehand to use this.

Alternatively, you can just store the frequently accessed information such as user name and picture in a separate node.

about 4 years ago · Santiago Gelvez 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!