“Collection <any>”类型中不存在“mapReduce”属性

时间:2017-01-12 02:42:34

标签: mongodb hadoop angular meteor typescript

美好的一天,我以这种方式定义了一个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"});
}

BUT服务器在启动时会抛出此错误:

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

任何想法可能导致什么?

0 个答案:

没有答案