var mapFunction1 = function() {
for (var i = 0; i < this.money.length; i++) {
emit("balance", this.money[i].amount);
}
};
var reduceFunction1 = function(keyBalance, valuesBalance) {
return Array.sum(valuesBalance);
};
db.users.mapReduce(mapFunction1, reduceFunction1, {
out : "balance"
})
db.balance.find()
However, an error has occurred
uncaught exception: map reduce failed:{ "errmsg" : "exception: TypeError: Cannot read property 'length' of undefined\n at _funcs1 (_funcs1:2:37) near 'is.money.length; i++) ' (line 2)", "code" : 16722, "ok" : 0