jstests/core/explain_delete.js
/**
 * Verify that the explain command output 'explain' shows a DELETE stage with an nWouldDelete
 * value equal to 'nWouldDelete'.
 */
Verify that the explain command output 'explain' shows a DELETE stage with an nWouldDelete
value equal to 'nWouldDelete'.
Verify that the explain command output ' explain ' shows a DELETE stage with an nWouldDelete value equal to ' nWouldDelete ' .
function checkNWouldDelete(explain, nWouldDelete) {
    printjson(explain);
    assert.commandWorked(explain);
    assert("executionStats" in explain);
    var executionStats = explain.executionStats;
    assert("executionStages" in executionStats);
    var execStages = executionStats.executionStages;
    if ("SHARD_WRITE" === execStages.stage) {
        var deleteStage = execStages.shards[0].executionStages;
        assert.eq(deleteStage.stage, "DELETE");
        assert.eq(deleteStage.nWouldDelete, nWouldDelete);
    }
    else {
        assert.eq(execStages.stage, "DELETE");
        assert.eq(execStages.nWouldDelete, nWouldDelete);
    }
}
function checkNWouldDelete ( explain , nWouldDelete ) { printjson ( explain ) ; assert . commandWorked ( explain ) ; assert ( "executionStats" in explain ) ; var executionStats = explain . executionStats ; assert ( "executionStages" in executionStats ) ; var execStages = executionStats . executionStages ; if ( "SHARD_WRITE" === execStages . stage ) { var deleteStage = execStages . shards [ 0 ] . executionStages ; assert . eq ( deleteStage . stage , "DELETE" ) ; assert . eq ( deleteStage . nWouldDelete , nWouldDelete ) ; } else { assert . eq ( execStages . stage , "DELETE" ) ; assert . eq ( execStages . nWouldDelete , nWouldDelete ) ; } }
Verify that the explain command output 'explain' shows a DELETE stage with an nWouldDelete
 value equal to 'nWouldDelete'.
Verify that the explain command output ' explain ' shows a DELETE stage with an nWouldDelete value equal to ' nWouldDelete ' .
// If passed through mongos, then DELETE should be below the SINGLE_SHARD mongos stage. // Otherwise it is the root stage.