jstests/change_streams/oplog_rewrite/projection_changes_type.js
// and confirms both that it succeeds and that all events in the original stream were observed.
and confirms both that it succeeds and that all events in the original stream were observed.
and confirms both that it succeeds and that all events in the original stream were observed .
function assertProjection(testProjection) {
    for (let projType of ["$project", "$addFields"]) {
        jsTestLog(`Testing projection: ${tojsononeline({[projType]: testProjection})}`);
        const projectedEvents = getAllChangeStreamEvents(
            testDB, [{[projType]: testProjection}], {showExpandedEvents: true}, startPoint);
        assert.eq(projectedEvents.map(elem => ({_id: elem._id})),
                  fullEvents.map(elem => ({_id: elem._id})));
    }
}
function assertProjection ( testProjection ) { for ( let projType of [ "$project" , "$addFields" ] ) { jsTestLog ( ` ${ tojsononeline ( { [ projType ] : testProjection } ) } ` ) ; const projectedEvents = getAllChangeStreamEvents ( testDB , [ { [ projType ] : testProjection } ] , { showExpandedEvents : true } , startPoint ) ; assert . eq ( projectedEvents . map ( elem => ( { _id : elem . _id } ) ) , fullEvents . map ( elem => ( { _id : elem . _id } ) ) ) ; } }
and confirms both that it succeeds and that all events in the original stream were observed.
and confirms both that it succeeds and that all events in the original stream were observed .
// Test both $project, which will exclude all but the specified computed fields, and $addFields, // which will retain all fields and overwrite the specified fields with the computed values. // Log the projection that we are about to test. // Read all events from the stream and apply the projection to each of them. // Assert that we see the same events in the projected stream as in the original.