Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
130
rated 0 times [  137] [ 7]  / answers: 1 / hits: 54927  / 11 Years ago, sat, december 21, 2013, 12:00:00
Post
.findAll({where: {tag: 'news'}, limit: 10})
.success(function(result) { ... })


How to insert the condition of sorting by date in my query with not using sequelize.query like



.findAll({ limit: 10, sort: [updatedAt, descending]})

More From » node.js

 Answers
40

@dankohn is correct and that will work but it is safer to use the following:



Post.findAll({ limit: 10, order: [['updatedAt', 'DESC']]});


as this




will escape updatedAt and validate DESC against a list of valid direction parameters



[#73619] Thursday, December 19, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
charity

Total Points: 503
Total Questions: 98
Total Answers: 125

Location: Mali
Member since Fri, Dec 3, 2021
3 Years ago
;