MongoJS runcommand for mapreduce returning error

616 Views Asked by At

I'm able to run the simple {ping:1} command with MongoJS in NodeJS, but when I try to run the mapreduce command I'm receiving an error. I've googled the crap out of the error and can't seem to find a resolution anywhere.

Successful command

db.runCommand({ping:1}, function(err, res){
    if(!err && res.ok){
        console.log("working")
    }
});

Unsuccessful command

db.runCommand({
    mapreduce: "videos",
    map: map,
    reduce: reduce,
    out: "tags"
},function(err, res){
    if(!err && res.ok){
        console.log("working")
    }
});

Error received

{ errmsg: 'exception: not code', code: 10062, ok: 0 }

Here are the mapFn and ReduceFn

var map = function() {
    if (!this.tags) {
        return;
    }

    for (index in this.tags) {
        emit(this.tags[index], 1);
    }
};

var reduce = function(previous, current) {
    var count = 0;

    for (index in current) {
        count += current[index];
    }

    return count;
};

I took this example straight from the MongoDB cookbook.

1

There are 1 best solutions below

0
On

Didn't find out exactly what the error was, but did find out how to use mapReduce with MongoJS in another SO post