Custom Search

Wednesday, May 8, 2019

How to Rename a field for all Documents in a MongoDB Collection

db.media.find()
db.media.updateMany( {}, { $rename: { "new_field1": "new_field3" } } )
db.media.find()
db.media.updateMany( {'city':'BARRE'}, { $rename: { "new_field3": "new_field4" } } )
db.media.find({'city':'BARRE'})

//db.media.updateMany( {}, { $rename: { "new_field1": "new_field3" } } )
//db.media.updateMany( {'city':'BARRE'}, { $rename: { "new_field3": "new_field4" } } )

No comments:

Post a Comment