sequelize order by date 1

sequelize order by date

Users.findAll({ order: [['updatedAt', 'DESC']]}); // or ASC

Here is what the above code is Doing:
1. We’re using the findAll() method to get all the users from the database.
2. We’re using the order option to sort the users by the updatedAt column.
3. We’re using the DESC option to sort the users in descending order.

Similar Posts