/**
* js add property do not work at emit()
*
* @link https: *
* Affected versions: r2.1.0-1580-g0c1a6bd (v8)
* v8 engine: Version 3.9.23
*
* Not affected versions: 2.0.3-1 (spider monkey)
*/
var testCollName = 'such-collection-can-t-exist';
var testColl = db.getCollection(testCollName);
testColl.insert({key: 1, foo: {bar: 1}});
testColl.insert({key: 1, foo: {bar: 1}});
testColl.insert({key: 1, foo: {bar: 1}});
res = db.runCommand({
mapreduce: testCollName,
map: function() {
this.foo.additional = 1;
assert(this.foo.additional, "additional not exist");
emit(this.key, {foo: this.foo});
},
reduce: function(k, vals) {
return 0;
},
out: {inline: 1}, });
printjson(res);
testColl.drop();