summaryrefslogtreecommitdiff
path: root/jstests/group2.js
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-09-10 15:45:31 -0400
committerEliot Horowitz <eliot@10gen.com>2009-09-10 15:45:31 -0400
commitcbb58275d2c68845ba1cce082b1949fb034c33fa (patch)
tree70b174ea4e26b543970d6cdf0c80b28fbf4d5b26 /jstests/group2.js
parent47a7238303990fbd9ebf8834d8abd2b7fc50fe72 (diff)
downloadmongo-cbb58275d2c68845ba1cce082b1949fb034c33fa.tar.gz
make group work better with nulls
Diffstat (limited to 'jstests/group2.js')
-rw-r--r--jstests/group2.js21
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");