にソート実行します。SailsJSは、ここに私の現在の<strong>イベントモデル</strong>です移入データ
module.exports = {
attributes: {
name: {
type: 'string',
required: true,
unique: true
},
client: {
model: 'client',
required: true
},
location: {
model: 'location',
required: true
}
}
};
クライアントモデル:私はclient name
に基づいてソートを実装するのですかそう
module.exports = {
attributes: {
name: {
type: 'string',
required: true,
unique: true
},
address: {
type: 'string'
},
clientContact: {
model: 'user',
required: true
}
}
};
また、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 –