I got this document in a collection
{
"_id" : ObjectId("1234"),
"title" : "Some Company",
"assignedPackages" : [
ObjectId("2345"),
ObjectId("3456"),
ObjectId("4567")
]
}
and this updateMany
db.getCollection("companies").updateMany(
{ _id: ObjectId("1234"), "assignedPackages": ObjectId("2345")},
{ $set: { "assignedPackages.$[elem]" : ObjectId("5432") }}, // , "updatedAt": "$$NOW"
{ arrayFilters: [ { "elem": ObjectId("2345") } ] }
)
When I run it it acknowledges the run and says 0 matched and updated. What am I doing wrong?