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

219
Visualizações
Firestore query by timestamp and another field

Using firestore v9 I faced up with 1 problem. I have a list of documents, and here 1 of them:

end_hour: 21 master: "WIZ1d74QmvMNDEQKulJyiQNCnad2" start_hour: 13 working_day: January 11, 2022 at 9:00:00 PM UTC+3

And I try to receive all documents, where master is equal as passed ID and working_day more than passed Date.

const response = await db.collection('schedule')
        .where('working_day', '>=', new Date())
        .where('master', '==', masterId)
        .get();

This request doesn't return any data at all, but when I do request using only first

const response = await db.collection('schedule')
        .where('working_day', '>=', new Date()).get()

or when I do query by second field

    const response = await db.collection('schedule')
        .where('master', '==', masterId)
        .get();

Both of them works alone, but not in a pair and I just don't know what is the problem

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

As mentioned by Caio, you'll need a composite index. From https://cloud.google.com/firestore/docs/query-data/queries#compound_queries, it says "You can chain multiple equality operators (== or array-contains) methods to create more specific queries (logical AND). However, you must create a composite index to combine equality operators with the inequality operators, <, <=, >, and !=."

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