dchester / epilogue

Create flexible REST endpoints and controllers from Sequelize models in your Express app
846 stars 116 forks source link

Order of associations #221

Open ClementParis016 opened 6 years ago

ClementParis016 commented 6 years ago

If I have a Discussion model plugged to a Message model through an hasMany relationship, how should I proceed to retrieve a specific discussion with its messages sorted in a particular order?

Setting a defaultScope with an { order: [['createdAt', 'DESC]] } on the Message model doesn't work, and setting sort: { default: '-createdAt' } in the message ressource doesn't work either.

kevboutin commented 5 years ago

Looks like I created the same sort of issue here: https://github.com/dchester/epilogue/issues/235

I did however provide an example, which may help demonstrate the issue better.