what i’m doing wrong?
db.products.updateMany({"images.url":"sampleURL"},{$set : {"images.url":"aaa"}})
db.products.updateMany({"images.url":"sampleURL"},{$set : {"images.url":"aaa"}})
Your images
property is an array of objects. So you can NOT update the field of an array. But you can update the field of each item in an array.
So, if you want to update the first item in an array, you would do it like this:
db.products.updateMany(
{ "images.url": "sampleURL" },
{ $set : { "images.0.url": "new_url" } }
)
Since the query part queries the array you may use
Definitely better solution.
but isn’t $update for for updating only a single value?
If $ does not work in updateMany, which I cannot test right now, you may use the arrayFilters: option of updateMany.