排序这里是我当前事件模型:SailsJS上执行数据填充
module.exports = {
attributes: {
name: {
type: 'string',
required: true,
unique: true
},
client: {
model: 'client',
required: true
},
location: {
model: 'location',
required: true
}
}
};
客户端型号:
module.exports = {
attributes: {
name: {
type: 'string',
required: true,
unique: true
},
address: {
type: 'string'
},
clientContact: {
model: 'user',
required: true
}
}
};
那么,如何实现排序基础上,client name
并且还有skip
和limit
财产(用于分页)与它一起工作。
我尝试使用下面的查询:
Event.find({ id: ['583eb530902db3d926345215', '583eb6dd91b972ee26dd97b1'] },
{ select: ['name', 'client'] })
.populate('client', { sort: 'name DESC' })
.exec((err, resp) => resp.map(r => console.log(r.name, r.client)));
但是,这似乎并没有做到这一点。
我相信你在找什么是这里:http://stackoverflow.com/questions/22996210/sort-by-the-association-with-populate –