排序這裏是我當前事件模型: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 –