Ordering results of eager-loaded models in Node Sequelize
I believe you can do:
db.Page.findAll({ include: [{ model: db.Gallery include: [{ model: db.Artwork }] }], order: [ [ db.Gallery, 'order', 'DESC' ], [ db.Gallery, db.ArtWork, 'order', 'DESC' ] ]})
If you also use 'as' and let's say you want to order by 'createdDate' , the query looks like this:
DbCategoryModel.findAll({ include: [ { model: DBSubcategory, as: 'subcategory', include: [ { model: DBProduct, as: 'product', } ], } ], order: [ [ {model: DBSubcategory, as: 'subcategory'}, {model: DBProduct, as: 'product'}, 'createdDate', 'DESC' ] ]})
order: [[ db.Sequelize.col('order'), 'DESC'], /*If you want to order by page module as well you can add this line*/[ db.Gallery, db.ArtWork, 'order', 'DESC' ]]