I have an object stored in MongoDB which looks like:
{
_id: 123
name: "xyz"
attrib:
{
address: "123 xyz rd",
phone: "123-456-7890"
}
}
I want to flatted this structure, so that there is no attrib field, I just have address and phone field along with name and _id.
So far, this is what I've tried:
db.emp.aggregate(
{
$project : {
{ addr : '$review.attrib.address' },
{ phn : '$review.votes.phone' },
}
}
);
Can anyone help me further?