summaryrefslogtreecommitdiff
path: root/jstests/core/index5.js
blob: 908b433c29985082ab79c6d2128a8b71afabe9f2 (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
// index5.js - test reverse direction index
//
// @tags: [requires_fastcount]

function validate() {
    assert.eq(2, t.find().count());
    f = t.find().sort({a: 1});
    assert.eq(2, t.count());
    assert.eq(1, f[0].a);
    assert.eq(2, f[1].a);
    r = t.find().sort({a: -1});
    assert.eq(2, r.count());
    assert.eq(2, r[0].a);
    assert.eq(1, r[1].a);
}

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

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

validate();

t.createIndex({a: -1});
validate();