1
我有3个表,如user
,userProfile
和userProfileImages
。 User
与userPrfoile
的映射一样多,并且userProfile
与userProfileImages
映射的一样多。Sequelize - SQL Server - 关联表排序
我需要编写订单查询userProfileImages
,我试过如下,但没有运气。
User.findById(uID, {
include: [
model: sequelize.models.userProfile
as: userProfile,
include: [
{
model: sequelize.models.userProfileImages,
as: 'profileImages',
}
],
order: [[sequelize.models.userProfileImages.id, "desc"]]
// order: [["id", "desc"]] --> Tried this way also no luck
] }
我得到的结果,但userProfilePicture
表的结果不符合递减。
请给予解决方案
请尝试使用单个数组而不是2d数组,如:[[“id”,“desc”]' – RaghavGarg
我试过了,但它不起作用。还有一件事,我还在第二个包含内做了一个映射。作为 –
按关键字排序也不附加在我的查询中。 –