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

137
Vistas
MongoDB $and use cases

What is the use cases of $and operator.

Looks like those are same

    this.matchModel.find({
      color: 'red',
      size: 'large'
    })

    this.matchModel.find({
      $and: [
        {
          color: 'red'
        },
        {
          size: 'large'
        }
      ]
    })

Aren't those same?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Yes, they mean the same, but they do make more sense if you want to combine it with other operators like $or. Consider the logic below, it makes code more readable too.

this.matchModel.find({
  $or: [
    {
      $and: [
        {
          size: { $gt: 1}
        },
        {
          size: { $lt: 5}
        }
      ]
    },
    {
      color: 'red'
    }
  ]
})

Here the logic is (size greater than 1 and less than 5) OR (color is red)

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