Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

224
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda