你好,我用这种方式定义了mongo集合:
Tasks = new Mongo.Collection<elementsType>("my_collection_name");
尝试对其执行mapreduce()调用后,请执行以下操作:
function mapReducing(): void {
let mapFunction = function () {
let idd = Math.floor((Math.random() * 10) + 1);
this.emit(idd, 10);
};
let reduceFunction = function (taskId, values) {
return values.reduce((a, b) => a + b, 0);
};
Tasks.mapReduce(mapFunction, reduceFunction, {out: "my_ouput_collection_name"});
}
但服务器在启动时抛出此错误:
Property 'mapReduce' does not exist on type 'Collection<any>'.
当我调用mapreducing()函数时,它会在上面显示错误:
Exception from sub testing id X69HTPSZmBqw8RMRd TypeError: index_1.Tasks.mapReduce is not a function
你知道这是什么原因吗?
暂无答案!
目前还没有任何答案,快来回答吧!