Answers for "add condition mongodb if field exists"

9

mongodb check if field exists

db.records.find( { a: { $exists: true } } )
Posted by: Guest on October-09-2020
-1

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 "add condition mongodb if field exists"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language