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
|
// @tags: [
// # This test attempts to remove documents using the stageDebug command, which doesn't support
// # specifying a writeConcern.
// assumes_write_concern_unchanged,
// ]
// Test basic delete stage functionality.
var coll = db.stages_delete;
var collScanStage = {cscan: {args: {direction: 1}, filter: {deleteMe: true}}};
var deleteStage;
// Test delete stage with isMulti: true.
coll.drop();
assert.writeOK(coll.insert({deleteMe: true}));
assert.writeOK(coll.insert({deleteMe: true}));
assert.writeOK(coll.insert({deleteMe: false}));
deleteStage = {
delete: {args: {node: collScanStage, isMulti: true}}
};
assert.eq(coll.count(), 3);
assert.commandWorked(db.runCommand({stageDebug: {collection: coll.getName(), plan: deleteStage}}));
assert.eq(coll.count(), 1);
assert.eq(coll.count({deleteMe: false}), 1);
// Test delete stage with isMulti: false.
coll.drop();
assert.writeOK(coll.insert({deleteMe: true}));
assert.writeOK(coll.insert({deleteMe: true}));
assert.writeOK(coll.insert({deleteMe: false}));
deleteStage = {
delete: {args: {node: collScanStage, isMulti: false}}
};
assert.eq(coll.count(), 3);
assert.commandWorked(db.runCommand({stageDebug: {collection: coll.getName(), plan: deleteStage}}));
assert.eq(coll.count(), 2);
assert.eq(coll.count({deleteMe: true}), 1);
assert.eq(coll.count({deleteMe: false}), 1);
|