我的文件:
{
currentRole: { title: "Engineer"}
}
期望输出
{
role: "Engineer"
}
试过这个:
let query = mongoose.model('cvs').aggregate(
[
{
$project: {
"currentRole.title":1,
"_id": 0
}
}
]
);
但这给出了:
{
"currentRole": {
"title": "Engineer"
}
},
如何创建具有标题值的新字段?
替换您的项目阶段以使用该字段的值,如下所示:
{
$project: {
"role": "$currentRole.title",
"_id": 0
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句