jstests/sharding/read_write_concern_defaults_commands_api.js
// generated by a getDefaultRWConcern command with inMemory=true.
generated by a getDefaultRWConcern command with inMemory=true.
generated by a getDefaultRWConcern command with inMemory = true .
function verifyFields(res, {expectRC, expectWC, isPersistedDocument}, isImplicitDefaultWCMajority) {
    let expectedFields = ["updateOpTime", "updateWallClockTime", "localUpdateWallClockTime"];
    let unexpectedFields = ["inMemory"];
    if (expectRC || !isPersistedDocument) {
        expectedFields.push("defaultReadConcern");
    } else {
        unexpectedFields.push("defaultReadConcern");
    }
    if (!isPersistedDocument) {
        expectedFields.push("defaultReadConcernSource");
    } else {
        unexpectedFields.push("defaultReadConcernSource");
    }
    if (expectWC || (isImplicitDefaultWCMajority && !isPersistedDocument)) {
        expectedFields.push("defaultWriteConcern");
    } else {
        unexpectedFields.push("defaultWriteConcern");
    }
    if (!isPersistedDocument) {
        expectedFields.push("defaultWriteConcernSource");
    } else {
        unexpectedFields.push("defaultWriteConcernSource");
    }
    if (isPersistedDocument) {
        expectedFields = expectedFields.filter(field => field !== "localUpdateWallClockTime");
        unexpectedFields.push("localUpdateWallClockTime");
    }
    assert.hasFields(res, expectedFields);
    unexpectedFields.forEach(field => {
        assert(!res.hasOwnProperty(field),
               `response unexpectedly had field '${field}', res: ${tojson(res)}`);
    });
    if (!isPersistedDocument) {
        if (expectWC) {
            assert.eq(res.defaultWriteConcernSource, "global", tojson(res));
        } else {
            assert.eq(res.defaultWriteConcernSource, "implicit", tojson(res));
        }
    }
}
function verifyFields ( res , { expectRC , expectWC , isPersistedDocument } , isImplicitDefaultWCMajority ) { let expectedFields = [ "updateOpTime" , "updateWallClockTime" , "localUpdateWallClockTime" ] ; let unexpectedFields = [ "inMemory" ] ; if ( expectRC || ! isPersistedDocument ) { expectedFields . push ( "defaultReadConcern" ) ; } else { unexpectedFields . push ( "defaultReadConcern" ) ; } if ( ! isPersistedDocument ) { expectedFields . push ( "defaultReadConcernSource" ) ; } else { unexpectedFields . push ( "defaultReadConcernSource" ) ; } if ( expectWC || ( isImplicitDefaultWCMajority && ! isPersistedDocument ) ) { expectedFields . push ( "defaultWriteConcern" ) ; } else { unexpectedFields . push ( "defaultWriteConcern" ) ; } if ( ! isPersistedDocument ) { expectedFields . push ( "defaultWriteConcernSource" ) ; } else { unexpectedFields . push ( "defaultWriteConcernSource" ) ; } if ( isPersistedDocument ) { expectedFields = expectedFields . filter ( field => field !== "localUpdateWallClockTime" ) ; unexpectedFields . push ( "localUpdateWallClockTime" ) ; } assert . hasFields ( res , expectedFields ) ; unexpectedFields . forEach ( field => { assert ( ! res . hasOwnProperty ( field ) , ` ${ field } ${ tojson ( res ) } ` ) ; } ) ; if ( ! isPersistedDocument ) { if ( expectWC ) { assert . eq ( res . defaultWriteConcernSource , "global" , tojson ( res ) ) ; } else { assert . eq ( res . defaultWriteConcernSource , "implicit" , tojson ( res ) ) ; } } }
generated by a getDefaultRWConcern command with inMemory=true.
generated by a getDefaultRWConcern command with inMemory = true .
// These fields are always set once a read or write concern has been set at least once. // localUpdateWallClockTime is generated by the in-memory cache and is not stored in the // persisted document.