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

215
Visualizações
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 à 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