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

106
Views
Cláusula condicional where de Firestore usando Modular SDK v9

¿Cómo realizar una consulta con la cláusula condicional where() usando Firebase Modular SDK (v9)?

Consulta de ejemplo en la versión con espacio de nombres (v8):

 const status = "live" const publishedAfter = 1630607348811 let q = firebase.firestore().collection("articles") // filters selected by users if (status) q = q.where("status", "==", "live") if (publishedAfter) q = q.where("publishedAt", ">", publishedAfter) const qSnapshot = await q.get()
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Opción 1: agregar condicionalmenteQueryConstraint usando el anterior como base

 let q = query(collection(firestore, "articles")) // filters selected by users if (status) q = query(q, where("status", "==", "live")) if (publishedAfter) q = query(q, where("publishedAt", ">", publishedAfter)) const qSnapshot = await getDocs(q);

Opción 2: agregar condicionalmente QueryConstraints a una matriz

 const constraints = [] // filters selected by users if (status) constraints.push(where("status", "==", "live")) if (publishedAfter) constraints.push(where("publishedAt", ">", publishedAfter)) const q = query(collection(firestore, "articles"), ...constraints) const qSnapshot = await getDocs(q);
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!