summaryrefslogtreecommitdiff
path: root/jstests/core/in2.js
blob: ddcee67ccd0e17aa3cc82c65b9e0d286f1596ca5 (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

t = db.in2;

function go(name, index) {
    t.drop();

    t.save({a: 1, b: 1});
    t.save({a: 1, b: 2});
    t.save({a: 1, b: 3});

    t.save({a: 1, b: 1});
    t.save({a: 2, b: 2});
    t.save({a: 3, b: 3});

    t.save({a: 1, b: 1});
    t.save({a: 2, b: 1});
    t.save({a: 3, b: 1});

    if (index)
        t.ensureIndex(index);

    assert.eq(7, t.find({a: {$in: [1, 2]}}).count(), name + " A");

    assert.eq(6, t.find({a: {$in: [1, 2]}, b: {$in: [1, 2]}}).count(), name + " B");
}

go("no index");
go("index on a", {a: 1});
go("index on b", {b: 1});
go("index on a&b", {a: 1, b: 1});