How to rename multiple fields (columns) in a MongoDB Collection (Table)

Sample to rename multiple fields at the same time in MongoDB:


db.yourCollectionName.updateMany( {}, { 
     $rename: { "field1OldName": "field1NewName",
                "field1OldName": "field2NewName" }
 } );


			

Leave a Reply