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

169
Vistas
Why does await model.find().sort() sorts elements but not the result array?
const products=await Product.find().sort("condition")

In the above snippet, Product is my mongoose model. The above snippet sorts the result according to the condition but the snippet below does not:

let products=await Product.find()
const results=products.sort("condition")

I am following the "Node.js Projects" by Coding Addict on Youtube where he says that this is because using await returns a list where we cannot use the mongoose.sort() function. So what I am trying to understand is why does the sort() function not work in the second snippet as I checked the types of the value returned in both snippets and it was Obj in both the cases.

about 4 years ago · Juan Pablo Isaza
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