Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda