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

168
Visualizações
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 à 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