1

I experienced a cyclic dependency error within mongoDB:

var mapFunction1 = function() {
        var key = this.sex;
        var value = {
                      count: 1,
                      price: this.height
                    };
        emit(key, value);
     };

var reduceFunction1 = function(keySEX, countObjVals) {
           reducedVal = { count: 0, height: 0 };
           for (var idx = 0; idx < countObjVals.length; idx++) {
                reducedVal.count += countObjVals[idx].count;
                reducedVal.height += countObjVals[idx].height;
           }
           return reducedVal;
     };

var finalizeFunction1 = function(key, reducedVal) {
           reducedVal.avg = reducedVal.height/reducedVal.count;
           return reducedVal;
};
db.runCommand(
   {
     mapReduce: db.people,
     map: mapFunction1,
     reduce: reduceFunction1,
     finalize: finalizeFunction1,
     query: {sex: "Male"},
     out: "wzrost_waga_avg"
   }
)

Anybody could point what is the issue here? Unfortunately I cannot pinpoint a place where I have made the mistake. Thanks!

ramo
  • 11
  • 2

0 Answers0