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

227
Visualizações
How to read all documents from collection in mongoose?

Seems to be a simple question, but I can't find the answer. There is a collection of posts, documents of which have a field rubric. How to read ALL documents from this collection in mongoose using Post.find ({rubric: value}, function), but keeping rubric. What value has to be for this to work?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

To find according if a field exists whatever value it has, you can use $exists in this way:

db.collection.find({
  "rubric": {
    "$exists": true
  }
})

Using mongoose is the same query. Something like this:

yourModel.find({
  "rubric": {
    "$exists": true
  }
})

Example here.

Also, to know about these world in mongo world you can check documentation every time you have an issue.

At the left of the page you see "Reference > Operators" and there are a lof of different operators you can use.

over 4 years ago · Santiago Trujillo 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