How do I apply order to includes
See original GitHub issueI’ve been trying to use this syntax but it does not seem to work, any ideas?
include: [
{ model: models.Image, as: 'IdeaHeaderImages', order: [['Image.updated_at','ASC']] }
]
From here: https://github.com/rbjarnason/your-priorities-app/blob/master/server_api/controllers/ideas.js#L97
Issue Analytics
- State:
- Created 8 years ago
- Reactions:65
- Comments:55 (7 by maintainers)
Top Results From Across the Web
node.js - Ordering results of eager-loaded nested models in ...
I need to be able to query the parent model 'Page' and include the associated models, and sort those associations by the field...
Read more >Sequelize — sort another Model in include by using order
I tried to join the team model with member model in a query, and the member needed to be sort by workYears ascending...
Read more >Sequelize - order by joined models | DailyCoding
To keep order in Sequelize we use order param. It gets an array of order specifications. These order specifications are also arrays, but...
Read more >include order sequelize - Code Examples & Solutions For This ...
Accesses.findAll({ include: [{ model: StationTypes, as: 'StationTypes', }], order: [['StationTypes', 'Order', 'ASC']], where: { ... }, }).then(...)
Read more >Ordering with included models | GoRails
Ordering with included models ... I am able to sort them by either numerical value or the related item name from the product...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yeah, the docs are really bad.
That syntax is not currently supported (except with
separate: truewhich only works for hasMany atm). You need to use the slighter longer/sweird syntax: