summaryrefslogtreecommitdiff
path: root/jstests/core/eval3.js
blob: 8cdd37239776eb53ad09e464f8ce8609dbd72ef7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Cannot implicitly shard accessed collections because unsupported use of sharded collection
// from db.eval.
// @tags: [assumes_unsharded_collection]

t = db.eval3;
t.drop();

t.save({_id: 1, name: "eliot"});
assert.eq(1, t.count(), "A");

function z(a, b) {
    db.eval3.save({_id: a, name: b});
    return b;
}

z(2, "sara");
assert.eq(2, t.count(), "B");

assert.eq("eliot,sara",
          t.find()
              .toArray()
              .map(function(z) {
                  return z.name;
              })
              .sort()
              .toString());

assert.eq("joe", db.eval(z, 3, "joe"), "C");
assert.eq(3, t.count(), "D");

assert.eq("eliot,joe,sara",
          t.find()
              .toArray()
              .map(function(z) {
                  return z.name;
              })
              .sort()
              .toString());