models.modelOne.findOne({
attributes: [ 'id', 'name' ],
where: { name },
include: [
{
model: models.modelTwo,
attributes: ['id', 'name'],
where: {name: nameTwo},
required: false
}
],
order: [
[ ???? ]
]
});
如何在“ id”上按型号订购?我需要通过'DESC'中的'id'通过modelOne对其进行排序 如果我喜欢
order: [
[ 'id', 'DESC' ]
]
我收到错误消息:
消息:“某列已按以下顺序多次指定: 清单。列表中的顺序中的列必须是唯一的。'
答案 0 :(得分:0)
查询中有两个var doctor = AllAppointments.GroupBy(a => a.Doctor.Id) //group on the doctor
.OrderByDescending(d => d.Count()) // order by the number of instances if the same doctor
.First() //grab the first one
列,一个来自id
,另一个来自modelOne
。只需从modelTwo
选项内的id
modelTwo
中删除attributes
。