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

194
Visualizações
Retrieve an child value and compare using firebase by javascript
    const uid = firebase.auth().currentUser.uid;

var query = firebase.database().ref("/user/").child(user.uid).orderByChild("l1").equalTo("bought ")
     query.on("value", function(snapshot) {
         var lg1=document.getElementById("lg1");
    var lg2=document.getElementById("lg2");
    var blg=document.getElementById("blg");
    lg2.style.display=" none";
    lg1.style.display="block"; 
    blg.style.display="block";
         
     });

I am comparing a child data in firebase realtime database and disable enable display using the snapshot function but it's not working I tried and research a lot but I couldn't find a perfect solution.

Any ideas on how to proceed above code?

Here is the screenshot of my firebase realtime database

Firebase realtime database

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Firebase queries work on the list of direct child nodes under the path that you query.

Since your query runs on /user/$uid, the nodes the query considers are email, l1, points and uid. For each of those it then looks for a child property l1 and compares the value to what you specified. But none of these four nodes has an l1 property.

If you want to be able to search the child nodes of /user/$uid for their l1 property, you need an extra level in the JSON, which is typically generated by calling push() as shown in the documentation on adding nodes to a list. So your JSON would become

user: {
  "$uid": {
    "$pushid": { // 👈 new
      email: "...",
      l1: "...",
      points: ...,
      uid: "...",
    }
  }
}

With that structure your query will work.

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