Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

214
Vistas
How to apply filters depending on if they're empty or not on firestore + javascript

I'm trying to apply some search filters for an application i'm developing that uses firestore and react. My problem is that when I want to filter the results I may use only 2 of the 4 fields I'm working with, and that gives an error, a different one depending on which way I get to the usecase.

My filter form is formed by 4 fields, type, subtype, calification, and name. for now im using just this kind of filter:

//This would be a query with one filter applied

getDocs(query(collection(db, "datosTest"),where("clasification", "==", clasificationMin)))

//If the user doesn't apply filters this is the query I want the program to make

getDocs(query(collection(db, "datosTest")))

I want to, if possible be able to add it to the query if it's different from null (or "" for that matter) and not having it append to the query if it is, in fact, empty.

Thanks in advance for your time

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda