Custom Search

Wednesday, May 8, 2019

How to add new field to every document in a MongoDB collection


db.media.find()
db.media.update({}, {$set : {"new_field1":1}}, {upsert:false, multi:true})

db.media.update({'city':'BARRE'}, {$set : {"new_field2":2}}, {upsert:false, multi:true})

db.media.find()
db.media.find({'city':'BARRE'})


//db.media.update({}, {$set : {"new_field1":1}}, {upsert:false, multi:true})
//db.media.update({'city':'BARRE'}, {$set : {"new_field2":2}}, {upsert:false, multi:true})

No comments:

Post a Comment