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

167
Views
How can I access the child of a unique key in Firebase?

I am trying to access the child value of a unique key value (that had been "pushed") within Firebase. Currently, my database looks like this: enter image description here I want to access the value of "emailOfUser"

I am very new to Firebase so I am not familiar with the functions. Currently, this is my method of obtaining other values for a different section of the database: enter image description here

Thank you so much for any feedback!

I've tried different methods to accessing this data within the Firebase, but I cannot get it to work/the methods I were using were outdated. I also tried to "update" the Firebase instead of "pushing" the values to prevent a unique key from generating, but it simply overwrote my current data rather than appending something new.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you want to load all the users who voted and print their emails, you can do that with:

get(child(dbref, 'usersWhoVoted')).then((snapshot) => {
  snapshot.forEach((childSnapshot) => {
    console.log(childSnapshot.key, childSnapshot.val().emailOfUser);
  });
})

Note that your current structure allows a user to vote multiple times. If you want to only allow them to vote once, use some identifier of the user as the key in your database structure:

userVotes: {
  "uniqueIdOfUser1": "valueTheyVotedOn",
  "uniqueIdOfUser1": "valueTheyVotedOn",
  ...
}

Now each user can by definition only vote once, If they vote again (assuming your security rules allow that), their new vote will simply replace the existing vote.

about 4 years ago · Juan Pablo Isaza 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!