summaryrefslogtreecommitdiff
path: root/jstests/core/index1.js
blob: 4c06bfe03fd4f912d9d9461b31676381dec1de81 (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
// @tags: [requires_non_retryable_writes]

t = db.embeddedIndexTest;

t.remove({});

o = {
    name: "foo",
    z: {a: 17, b: 4}
};
t.save(o);

assert(t.findOne().z.a == 17);
assert(t.findOne({z: {a: 17}}) == null);

t.createIndex({"z.a": 1});

assert(t.findOne().z.a == 17);
assert(t.findOne({z: {a: 17}}) == null);

o = {
    name: "bar",
    z: {a: 18}
};
t.save(o);

assert.eq.automsg("2", "t.find().length()");
assert.eq.automsg("2", "t.find().sort( { 'z.a' : 1 } ).length()");
assert.eq.automsg("2", "t.find().sort( { 'z.a' : -1 } ).length()");

assert(t.validate().valid);