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

90
Visualizações
How to add query operators to query of Firestore?

I have problem. My app allows user to filter offers by few params. I would like to fetch data with .where() operator by I need to stack them. How can I do it?

My attempt (don't work):

let query = db.collection("cards").where("cardId", "==", id);

  if (filterParams.price.from && filterParams.price.to) {
    query
      .where("price", ">=", filterParams.price.from)
      .where("price", "<=", filterParams.price.to);
  }
  if (filterParams.graded) {
    query.where("isGraded", "==", filterParams.graded);
  }
  if (filterParams.condition) {
    query.where("condition", "==", filterParams.condition);
  }

  query = await query.get();
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Query objects are immutable. Each time you call where it returns a new Query object, which you need to then keep a reference to that query.

So:

let query = db.collection("cards").where("cardId", "==", id);

if (filterParams.price.from && filterParams.price.to) {
  query = query // 👈
    .where("price", ">=", filterParams.price.from)
    .where("price", "<=", filterParams.price.to);
}
if (filterParams.graded) {
  query = query.where("isGraded", "==", filterParams.graded); // 👈
}
if (filterParams.condition) {
  query = query.where("condition", "==", filterParams.condition); // 👈
}

query = await query.get();
about 4 years ago · Juan Pablo Isaza 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