Description
if initial contains an attribute whose value is null, an exception will be thrown:
Tue Jun 7 14:57:50 uncaught exception: group command failed:
{ "errmsg" : "exception: reduce invoke failed: JS Error: TypeError: invalid 'in' operand v shell/utils.js:218", "code" : 9010, "ok" : 0 }to reproduce:
> db.mycoll.group({ key: { _id: true }, initial: { a: 0 }, reduce: function(o, p) { } }) |
[ { "_id.hid" : 360, "a" : 0 } ] |
> db.mycoll.group({ key: { _id: true }, initial: { a: null }, reduce: function(o, p) { } }) |
Tue Jun 7 14:57:50 uncaught exception: group command failed: {
|
"errmsg" : "exception: reduce invoke failed: JS Error: TypeError: invalid 'in' operand v shell/utils.js:218", |
"code" : 9010, |
"ok" : 0 |
}
|
it would be useful to be able to use an initial attribute with a null value for computing min/max values where the range is not known:
function(o, p) {
|
if (p.min == null || o.value < p.min) { p.min = o.value; }
|
if (p.max == null || o.value > p.max) { p.max = o.value; }
|
... other reduce computations ...
|
}
|