Reputation: 103
class PostagemController {
static async pegaTodasPostagens(req,res){
try{
const todasPostagens=await database.Postagens.findAll({order:
['id','DESC']
})
return res.status(200).json(todasPostagens)
}catch (error){
return res.status(500).json(error.message)
}
}
I'm trying this way, but this message appears on the postman
"Unknown column 'Postagens.DESC' in 'order clause'"
Upvotes: 0
Views: 997
Reputation: 22783
The order
option should be an array of array in case when you wish to indicate a sorting direction otherwise Sequelize treats a flat array as an array of column names:
const todasPostagens=await database.Postagens.findAll({order:
[['id','DESC']]
})
Upvotes: 2