Answers for "mongodb add or update document fields only if they don't exist"

0

mongodb add or update document fields only if they don't exist

db.foo.update({'field': {$exists : false}}, {$set: {'field': ''}})
// for multiple update do this
db.foo.update({'field': {$exists : false}}, {$set: {'field': ''}}, false, true)
Posted by: Guest on August-03-2021

Code answers related to "mongodb add or update document fields only if they don't exist"

Code answers related to "Javascript"

Browse Popular Code Answers by Language