summaryrefslogtreecommitdiff
path: root/jstests/core/group9.js
blob: a7d9a0d128e4f5143475d9b97d4e2b1d57d60721 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
(function() {
    'use strict';
    var t = db.group_owned;
    t.drop();

    assert.writeOK(t.insert({_id: 1, subdoc: {id: 1}}));
    assert.writeOK(t.insert({_id: 2, subdoc: {id: 2}}));

    var result = t.group({
        key: {'subdoc.id': 1},
        reduce: function(doc, value) {
            value.subdoc = doc.subdoc;
            return value;
        },
        initial: {},
        finalize: function(res) {}
    });

    assert(result.length == 2);
}());