My document:
{
currentRole: { title: "Engineer"}
}
Desired output
{
role: "Engineer"
}
Tried this:
let query = mongoose.model('cvs').aggregate(
[
{
$project: {
"currentRole.title":1,
"_id": 0
}
}
]
);
But this gives:
{
"currentRole": {
"title": "Engineer"
}
},
How can I created a new field with the title value?