Sequelize - SQL Server - order by for association tables

前端 未结 2 882
后悔当初
后悔当初 2021-01-02 18:19

I have 3 tables such as user, userProfile and userProfileImages. User is mapping with userPrfoile as has man

2条回答
  •  一生所求
    2021-01-02 18:40

    Update your order in association like below

    User.findById(uID, { 
    include: [
        model: sequelize.models.userProfile,
        as: userProfile,        
        include: [{
           model: sequelize.models.userProfileImages,
           as: 'profileImages',
           separate:true
           order: [['id', 'desc']]
        }],
    ]});
    

提交回复
热议问题