Hi Edwin,
Continuing to what Peter mentioned, here is a sample query that you can try
db.collection.aggregate([
{
$addFields: {
foos: {
$arrayToObject: {
$map: {
input: "$foos",
as: "foo",
in: {
k: "$$foo.code",
v: "$$foo.article.$id"
}
}
}
}
}
}
]);