diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-09-10 15:45:31 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-09-10 15:45:31 -0400 |
commit | cbb58275d2c68845ba1cce082b1949fb034c33fa (patch) | |
tree | 70b174ea4e26b543970d6cdf0c80b28fbf4d5b26 /jstests | |
parent | 47a7238303990fbd9ebf8834d8abd2b7fc50fe72 (diff) | |
download | mongo-cbb58275d2c68845ba1cce082b1949fb034c33fa.tar.gz |
make group work better with nulls
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/group2.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/jstests/group2.js b/jstests/group2.js new file mode 100644 index 00000000000..7b85ddf9e5f --- /dev/null +++ b/jstests/group2.js @@ -0,0 +1,21 @@ +t = db.group2; +t.drop(); + +t.save({a: 2}); +t.save({b: 5}); +t.save({a: 1}); + +result = t.group({key: {a: 1}, + initial: {count: 0}, + reduce: function(obj, prev) { + prev.count++; + }}); + +assert.eq(3, result.length, "A"); +assert.eq(null, result[1].a, "C"); +assert("a" in result[1], "D"); +assert.eq(1, result[2].a, "E"); + +assert.eq(1, result[0].count, "F"); +assert.eq(1, result[1].count, "G"); +assert.eq(1, result[2].count, "H"); |