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

1.6K
Vistas
Mongodb Query giving error: Expression $gt takes exactly 2 arguments. 1 were passed in

I am writting the following query to retrive the records based on 2 conditions.Executing the Query giving me error:

> db.employee.find({age:{$lt:32}},{salary:{$lt:40000}})

Here is the error Message:

Error: error: {
        "ok" : 0,
        "errmsg" : "Expression $lt takes exactly 2 arguments. 1 were passed in.",
        "code" : 16020,
        "codeName" : "Location16020"
}
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

To do a find query based in two conditions, you need to do in the same query object.

Note that you are doing:

find({obj1},{obj2}

But second parameter into find method is for projection (docs)

So you need this query:

db.collection.find({
  "age": {
    "$lt": 32
  },
  "salary": {
    "$lt": 40000
  }
})

Note how there is only one object with two fields: age and salary.
Something like find( { age:{}, salary:{}} ).

Example here

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