Update nested array for multiple documents in a collection

Hi i was trying to update some data in a nested array and for multiple documents in a collection.
but i have some issue with updating multiple fields by using the following script

db.profiles.updateMany(
   { $or : [ { "contacts.phone_number":{$exists : 1} },{ "contacts.address":{$exists : 1} },{ "contacts.email":{$exists : 1} } ] },
   { $set: { 
      "contacts.phone_number.$[element].type" :"Work",
      "contacts.address.$[element].type" :"Work",
      "contacts.email.$[element].type" :"Work",
      "contacts.phone_number.$[element].is_enabled" : 1,
      "contacts.address.$[element].is_enabled" : 1,
      "contacts.email.$[element].is_enabled" : 1,
      }
   },      
   {arrayFilters: [ { "element.type": {$exists : 0} ,"element.is_enabled": {$exists : 0} }] }
)

can anyone suggest me a better way to do this ?

Hello @Idayachelvan_Balakrishnan, Welcome to the MongoDB community forum :slight_smile:

Could you please share some example documents and explain a bit what is the exact issue you are facing?