I am trying to convert a mongoDB documents object into an array with the same data. I have a document structured like this:
{
_id:"43434",
fistname: 'Bob',
lastname: 'Toto',
address: { city: "cityName", postalCode: "000000", streetName: "streetname" },
}
And I want to restructure my data like this :
{
_id:"43434",
fistname: 'Bob',
lastname: 'Toto',
address: [{ city: "cityName", postalCode: "000000", streetName: "streetname" }],
}
How would I go about achieving that? Can I use the $project (aggregation) of mongo?