const $ = db.command.aggregate const p2 = db.collection('pay').aggregate() .match({ card: app.globalData.card }) .group({ _id: '$period' }) .end() p2.then(result => { if (result.list.length > 0) { const mydata = []; for (var i = 0; i < result.list.length; i++) { mydata.push(result.list[i]._id) } mydata.sort().reverse(); this.setData({ dateArray: mydata, //获取数据数组 index: 0, }); this.getData(); } else { this.setData({ hidden: true }); } })
如何输出aggregate的结果?请问一下如何输出aggregate后的结果? const $ = db.command.aggregate let temp=db.collection('recordmovement').aggregate() .match({ _openid: '5aO_tBixeUe2ULs6Z4fQ6yI' }) .bucket({ groupBy: '$movement', boundaries: ['1', '50'], default: 'other', output: { count: $.sum('$_id'), ids: $.push('$_id') } }) .end(); 如果直接console.log(temp),则直接输出Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined
2019-08-28