Skip to content Skip to sidebar Skip to footer

Mongodb Mapreduce Scope - ReferenceError

I'm trying to use an external object inside mongodb map/reduce functions. If the object has a variable which it should access, an error occurs. For example: var conn = new Mongo();

Solution 1:

What's casuing the problem is this function:

var HelperClass = function() {
  var v = [1, 2, 3];

  this.data = function() {
    return v.data;
  };
};

Since:

return v.data;

Is in a different scope to the real variable which is actually this.v.data.


Post a Comment for "Mongodb Mapreduce Scope - ReferenceError"