Add New Field To Every Document In Mongodb

[Solved] Add New Field To Every Document In Mongodb | Perl - Code Explorer | yomemimo.com
Question : how to add a new propety into all documents in mongodb

Answered by : prathamesh-mali

db.users.update({}, { "$set" : { "age": 30 }}, false,true)
// users: collection name, age: new property
//false it's upsert argument, it tells mongo to not insert a new document when no match is found
// true it's multi argument, it tells mongo to update multiple documents that meet the query criteria

Source : | Last Update : Thu, 24 Sep 20

Answers related to add new field to every document in mongodb

Code Explorer Popular Question For Perl