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

221
Visualizações
MongoDB Ignoring Filter

Either I'm missing something or is this a possible Node.js driver issue?

const users = await User.find({ 'test.test': { $gt: 0 } }).lean();

None of my User documents contain the test object, therefore none should meet this filter's criteria. However, instead of returning no documents, it's returning all of my user documents. According to the documentation, it should only ever return all of the documents in a collection if no/empty filters are passed?

Edit: I said ignoring filter as it only seems to occur when applying nested filters on undefined properties. For instance, if I add more filter conditions that a few documents meet they'll apply *correctly. Example: User.find({ username: { $exists: true }, 'test.test': { $gt: 0 } }) returns only the user documents where username exists, however they still don't have the test object.

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

0

The issue was resolved by setting the Mongoose Schema strictQuery option to false.

https://mongoosejs.com/docs/guide.html#strictQuery

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