I get difficult to add key into the aggregate from array object
here is the data which I want to aggregate
// COMPANY
{
"name": "Note Inc",
"shortName": "The Note",
"members": [
{
"_id": ObjectId("5efdac62cd210f3b658d98f6"),
"status": false,
"role": "chairman",
},
{
"_id": ObjectId("5effac62dd210f9b658d98f1"),
"status": true,
"role": "admin",
}
]
}
and the result I want
// COMPANY after aggregate the Person
{
"name": "Note Inc",
"shortName": "The Note",
"members": [
{
"_id": ObjectId("5efdac62cd210f3b658d98f6"),
"name": "Shinta",
"gender": "female"
"status": false,
"role": "chairman",
},
{
"_id": ObjectId("5effac62dd210f9b658d98f1"),
"name": "John",
"gender": "male"
"status": true,
"role": "admin",
}
]
}
in my case here I am using Go, but I need the vanilla Mongo Query for this so I can translate into Go query pipeline