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

Your email address will not be published. Required fields are marked *

Recent Posts

Archives

Categories

Meta

All Rights Reserved Theme by 404 THEME.