如何使用mongoose羽毛适配器编写一个聚合体?

我是feathersjs框架的新手,并试图写聚合查询它不能正常工作。

hook.app.query = { lookup: { from: "orders", localField:"serviceLocationId", foreignField:"serviceLocationId", as: "orders" }, match: { serviceLocationId : { $in: Array.from(new Set(reqArr)) } }, limit: 14 } hook.app.service('servicelocations') .find(hook.app.query) .then(result => { console.log(result) }) 

我们需要使用下面的方式service.Model.aggregate然后它的工作正常

 function locations(hook) { return new Promise((resolve,reject) =>{ hook.app.service('location') .Model.aggregate(hook.app.query) .then(result => { resolve(result) }).catch(e=>{ reject(e) }) }) } 
Interesting Posts