【发布时间】:2017-04-03 06:27:49
【问题描述】:
这是我目前的事件模型:
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)));
但这似乎没有这样做。
【问题讨论】:
-
相信你要找的就在这里:stackoverflow.com/questions/22996210/…
标签: node.js mongodb sails.js waterline sails-mongo