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.

{ 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

I wanted to replace this string staticflyo to helloworld


Any help please

You can use the arrayFilters operator:

  $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.