With Mongo 4.2.5 and this collection
db.foo.insert({foo:["bar", "baz"]})
when trying to copy the "baz" in the array to a new field named foobaz like this in the shell:
db.foo.updateMany({}, [{$set:{foobaz: "$foo.1"}}])
I get an object like this
{
_id: fooid,
foo: ["bar", "baz"],
foobaz: []//empty array instead of "baz"
}
What am i doing wrong ?