blob: 598cd7a9e11a4f0687b8d2e690f6f8275922d2f6 (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// Test explain of various operations against a non-existent database
(function() {
var explainMissingDb = db.getSiblingDB("explainMissingDb");
var explain;
var explainColl;
// .find()
explainMissingDb.dropDatabase();
explain = explainMissingDb.collection.explain("executionStats").find().finish();
assert.commandWorked(explain);
assert("executionStats" in explain);
// .count()
explainMissingDb.dropDatabase();
explain = explainMissingDb.collection.explain("executionStats").count();
assert.commandWorked(explain);
assert("executionStats" in explain);
// .group()
explainMissingDb.dropDatabase();
explainColl = explainMissingDb.collection.explain("executionStats");
explain = explainColl.group({key: "a", initial: {}, reduce: function() {}});
assert.commandWorked(explain);
assert("executionStats" in explain);
// .remove()
explainMissingDb.dropDatabase();
explain = explainMissingDb.collection.explain("executionStats").remove({a: 1});
assert.commandWorked(explain);
assert("executionStats" in explain);
// .update() with upsert: false
explainMissingDb.dropDatabase();
explainColl = explainMissingDb.collection.explain("executionStats");
explain = explainColl.update({a: 1}, {b: 1});
assert.commandWorked(explain);
assert("executionStats" in explain);
// .update() with upsert: true
explainMissingDb.dropDatabase();
explainColl = explainMissingDb.collection.explain("executionStats");
explain = explainColl.update({a: 1}, {b: 1}, {upsert: true});
assert.commandWorked(explain);
assert("executionStats" in explain);
// .aggregate()
explainMissingDb.dropDatabase();
explain = explainMissingDb.collection.explain("executionStats").aggregate([{$match: {a: 1}}]);
assert.commandWorked(explain);
}());
|