2022-03-07

MongoDB - Update all collection documents with a new copy of an existing field

 db.COLLECTION_NAME.update(

    {

        FIELD_1: ANY_VALUE

    },

    [

        {$set: {

            "NEW_FIELD_COPY": "$ORIGINAL_SOURCE_FIELD", 

        }},

    ],

    {

        multi: true, 

        upsert: false,

    }

);

No comments:

Post a Comment