【发布时间】:2016-12-22 06:11:36
【问题描述】:
我有一个大型聚合查询,要求我将“allowDiskUse:true”作为选项传递。这不适用于此处描述的聚合: https://github.com/meteorhacks/meteor-aggregate/issues/11
这里定义了我的流星方法。当我调用该方法时,我需要等待 ondata 完成,然后再将任何内容返回给客户端,但是我尝试的任何方法都无法让我以安全的方式将数据发送到前端。
Meteor.methods({
'getSummary': function (dept,startDate,endDate,filterType) {
f = myQuery(startdate,enddate,dayFinalGroup);
f.on("data", Meteor.bindEnvironment(function(row) {
//load an array or something here to return
}));
f.once("end", Meteor.bindEnvironment(function() {
// tidy up, in my case end the stream
}));
//here I'd return the array loaded
},
});
这是我的前端。
Meteor.call(
'getSummary',0,Session.get('start_date'),Session.get('end_date'),1,
function(error, result){
if(error){
console.log(error);
} else {
Session.set('sumTotals',result);
}
}
);
【问题讨论】: