By using 2 consecutive addField stages using map I can get it so that the data is like so
foos: [
{k: "ABC", v: "#ID1#"},
{k: "DEF", v: "#ID2#"},
]
which is almost there but when I try to convert the foos objects into arrays with this stage
$addFields: {
"foos": {
$map: {
input: "$foos",
in: {
$pbjectToArray: "$$this"
}
}
}
}
it turns into this which is much worse seems to be converting the array into objects
foos: [
[{"k":"k", "v":"ABC"},{"k":"v", "v":"#ID1#"}]
]