We have a requirement to insert to the sub array when sub array contains some value, but I get an error when using push with arrayFilter:
fail to run update: write exception: write errors: [The field 'subArr.0' must be an array but is of type object in document {_id: "1"}]
You can reproduce it using the playground.
db.collection.update({},
{
$push: {
"subArr.$[a0]": {
"input1": "c",
"title": "s3"
}
}
},
{
arrayFilters: [
{
"a0.title": {
"$eq": "s1"
}
}
]
})