jstests/core/timeseries/timeseries_update.js
/**
     * Confirms that a set of updates returns the expected set of documents.
     */
Confirms that a set of updates returns the expected set of documents.
Confirms that a set of updates returns the expected set of documents .
function testUpdate({
        initialDocList,
        updateList,
        resultDocList,
        n,
        nModified = n,
        letDoc = {},
        failCode = null,
        hasMetaField = true,
        ordered = true
    }) {
        const coll = testDB.getCollection('t');
        assert.commandWorked(testDB.createCollection(coll.getName(), {
            timeseries: hasMetaField ? {timeField: timeFieldName, metaField: metaFieldName}
                                     : {timeField: timeFieldName},
        }));
        assert.commandWorked(insert(coll, initialDocList));
        const updateCommand =
            {update: coll.getName(), updates: updateList, ordered: ordered, let : letDoc};
        const res = failCode
            ? assert.commandFailedWithCode(testDB.runCommand(updateCommand), failCode)
            : assert.commandWorked(testDB.runCommand(updateCommand));
        assert.eq(n, res.n);
        assert.eq(nModified, res.nModified);
        assert.eq(initialDocList.length, resultDocList.length);
        resultDocList.forEach(resultDoc => {
            assert.docEq(resultDoc,
                         coll.findOne({_id: resultDoc._id}),
                         "Expected document not found in result collection:" +
                             tojson(coll.find().toArray()));
        });
        assert(coll.drop());
    }
function testUpdate ( { initialDocList , updateList , resultDocList , n , nModified = n , letDoc = { } , failCode = null , hasMetaField = true , ordered = true } ) { const coll = testDB . getCollection ( 't' ) ; assert . commandWorked ( testDB . createCollection ( coll . getName ( ) , { timeseries : hasMetaField ? { timeField : timeFieldName , metaField : metaFieldName } : { timeField : timeFieldName } , } ) ) ; assert . commandWorked ( insert ( coll , initialDocList ) ) ; const updateCommand = { update : coll . getName ( ) , updates : updateList , ordered : ordered , let : letDoc } ; const res = failCode ? assert . commandFailedWithCode ( testDB . runCommand ( updateCommand ) , failCode ) : assert . commandWorked ( testDB . runCommand ( updateCommand ) ) ; assert . eq ( n , res . n ) ; assert . eq ( nModified , res . nModified ) ; assert . eq ( initialDocList . length , resultDocList . length ) ; resultDocList . forEach ( resultDoc => { assert . docEq ( resultDoc , coll . findOne ( { _id : resultDoc . _id } ) , "Expected document not found in result collection:" + tojson ( coll . find ( ) . toArray ( ) ) ) ; } ) ; assert ( coll . drop ( ) ) ; }
Confirms that a set of updates returns the expected set of documents.
Confirms that a set of updates returns the expected set of documents .