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

253
Visualizações
Firebase Query and how to read the output

enter image description here

Above is my Js code

I have a database that has information regarding the location of an apartment, I am trying to search for a specific property to see if it exists in the database. The user will be able to key into the search box to perform the search.

"propertiesRef" is used to store the user input. I tried storing the data into "q" that I received from querying the database. But I have no idea how to read the result.

enter image description here

This is the console log for "q", but I don't quite understand the information that is shown, I want to know which output in the console should I be looking at and how do I access them?

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

The query() function just creates an instance Query. You need to use getDocs() function to actually fetch data from Firestore.

const search = (property) => {
  const propertiesRef = collection(db, "flats-table");

  const q = query(propertiesRef, where("name", "==", property))

  return getDocs(q).then((qSnap) => {
    const data = qSnap.docs.map(d => ({ id: d.id, ...d.data() }))
    console.log(data);
    return data;
  }) 

  // or use async-await
  // const qSnap = await getDocs(q);
}

Checkout the documentation for more examples.

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