Doing Find and Replace of all instance of the search match inside the array

I wanted to search and replace one image url. On a single document based collection this following code worked for me.

db.mycollection.updateMany(
{ thumbnail_url: { $regex: /no-img-xx.png/ } },
  [{
    $set: { thumbnail_url: {
      $replaceOne: { input: "$URL", find: "no-img-xx.png", replacement: "no-img.png" }
    }}
  }]
)

However i have another collection in which the documents are inside the array
image

I wanted to replace this string staticflyo to helloworld

items.url

Any help please

You can use the arrayFilters operator:

db.collection.update({},
{
  $set: {
    "data.$[element].url": "boo"
  }
},
{
  arrayFilters: [
    {
      "element.url": "hello"
    }
  ],
  multi: true
})

You can put some moderately complex logic in the array filters should the need arise as well as have multi dimensional updates, i.e.

data.$[level1].modedata.$[level2].deepValue