jstests/sharding/update_compound_shard_key.js
/**
 * For upserts this will insert a new document, for non-upserts it will be a no-op.
 */
For upserts this will insert a new document, for non-upserts it will be a no-op.
For upserts this will insert a new document for non - upserts it will be a no - op .
function assertUpdateWorkedWithNoMatchingDoc(query, update, isUpsert, inTransaction) {
    const res = sessionDB.coll.update(query, update, {upsert: isUpsert});
    assert.commandWorked(res);
    assert.eq(isUpsert ? 1 : 0, res.nUpserted);
    assert.eq(0, res.nMatched);
    assert.eq(0, res.nModified);
    if (Array.isArray(update) || inTransaction)
        return;
    assert.eq(isUpsert ? 1 : 0,
              st.s.getDB(kDbName).coll.find(update["$set"] ? update["$set"] : update).itcount());
}
function assertUpdateWorkedWithNoMatchingDoc ( query , update , isUpsert , inTransaction ) { const res = sessionDB . coll . update ( query , update , { upsert : isUpsert } ) ; assert . commandWorked ( res ) ; assert . eq ( isUpsert ? 1 : 0 , res . nUpserted ) ; assert . eq ( 0 , res . nMatched ) ; assert . eq ( 0 , res . nModified ) ; if ( Array . isArray ( update ) || inTransaction ) return ; assert . eq ( isUpsert ? 1 : 0 , st . s . getDB ( kDbName ) . coll . find ( update [ "$set" ] ? update [ "$set" ] : update ) . itcount ( ) ) ; }
For upserts this will insert a new document, for non-upserts it will be a no-op.
For upserts this will insert a new document for non - upserts it will be a no - op .
// Skip find based validation for pipleline update or when inside a transaction. // Make sure that the upsert inserted the correct document or update did not insert // anything.