I'm working on a a MapReduce execution on my Node.js + Express.js server.
I'm using Mongoose as ODM, and I need to pass a key-value array named _affinities into the map function global scope. To do this, I'm currently passing the array inside the o.scope object:
var o = {}; // Object sent to Mongoose as options
// Scope to pass affinities
o.scope = {
affs : _affinities,
test : 'test'
}
However, while using those values in o.map, it says affs is an empty array. However, if I try to log test, it shows the correct value.
// Note: this is just a test, I don't need to pass affs & test as the key.
o.map = function() {
emit({
a : affs,
test : test,
id : this._id
}, this.score);
}
I have only one finalize function (for testing), without a reduce one.
o.finalize = function (k, v)
{
return v;
}
MyModel.mapReduce(o, callback);
Am I doing something wrong? Is not supported by MongoDB passing arrays?