Custom Search

Wednesday, May 8, 2019

How to remove a field completely from a MongoDB document

db.media.find()
db.media.update({}, {$unset: {"new_field3": 1}},  {multi: true})
db.media.find()

db.media.find({'city':'BARRE'})
db.media.update({'city':'BARRE'}, {$unset: {"new_field2": 10}},  {multi: true})


//db.media.update({}, {$unset: {"new_field3": 1}},  {multi: true})
//db.media.update({'city':'BARRE'}, {$unset: {"new_field2": 10}},  {multi: true})

No comments:

Post a Comment