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

250
Views
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 answers
Answer question

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 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!