jstests/core/find_and_modify_server6865.js
/**
     * Asserts that the specified query and projection returns the expected
     * result, using both the find() operation and the findAndModify command.
     *
     *   insert -- document to insert after dropping collection t
     *   cmdObj -- arguments to the findAndModify command
     *
     *   expected -- the document 'value' expected to be returned after the
     *               projection is applied
     */
Asserts that the specified query and projection returns the expected
result, using both the find() operation and the findAndModify command.

- document to insert after dropping collection t
cmdObj -- arguments to the findAndModify command

- the document 'value' expected to be returned after the
projection is applied
Asserts that the specified query and projection returns the expected result using both the find () operation and the findAndModify command . - document to insert after dropping collection t cmdObj -- arguments to the findAndModify command - the document ' value ' expected to be returned after the projection is applied
function testFAMWorked(insert, cmdObj, expected) {
        t.drop();
        t.insert(insert);
        var res;
        if (!cmdObj['new']) {
            res = t.findOne(cmdObj['query'], cmdObj['fields']);
            assert.eq(res, expected, 'positional projection failed for find');
        }
        res = t.runCommand('findAndModify', cmdObj);
        assert.commandWorked(res, 'findAndModify command failed');
        assert.eq(res.value, expected, 'positional projection failed for findAndModify');
        if (cmdObj['new']) {
            res = t.findOne(cmdObj['query'], cmdObj['fields']);
            assert.eq(res, expected, 'positional projection failed for find');
        }
    }
function testFAMWorked ( insert , cmdObj , expected ) { t . drop ( ) ; t . insert ( insert ) ; var res ; if ( ! cmdObj [ 'new' ] ) { res = t . findOne ( cmdObj [ 'query' ] , cmdObj [ 'fields' ] ) ; assert . eq ( res , expected , 'positional projection failed for find' ) ; } res = t . runCommand ( 'findAndModify' , cmdObj ) ; assert . commandWorked ( res , 'findAndModify command failed' ) ; assert . eq ( res . value , expected , 'positional projection failed for findAndModify' ) ; if ( cmdObj [ 'new' ] ) { res = t . findOne ( cmdObj [ 'query' ] , cmdObj [ 'fields' ] ) ; assert . eq ( res , expected , 'positional projection failed for find' ) ; } }
Asserts that the specified query and projection returns the expected
 result, using both the find() operation and the findAndModify command.
Asserts that the specified query and projection returns the expected result using both the find () operation and the findAndModify command .
// Test that the find operation returns the expected result. // Test that the findAndModify command returns the expected result. // Test that the find operation returns the expected result.