只查找条件匹配的特定内部数组,忽略其他| MongoDB | Node Js



在mongoose中,我试图获取与特定条件匹配的内部记录。但是它总是返回两个记录,就像它只处理父节点而不是子节点一样。

$项目聚合函数似乎不像我预期的那样工作'

[{
"_id": {
"$oid": "636b9958d6ea5d0cc85d20a6"
},
"project_type": 1,
"title": "Pariatur Aut repreh",
"id": 4,
"drawings": [
{
"id": 1,
"assigned_to": 4,
"assigned_name": "Desirae Sandoval",
"assigned_by": 3
},
{
"id": 1,
"assigned_to": 6,
"assigned_name": "Desirae Sandoval",
"assigned_by": 3
}
],
"status": 1,
"created_at": {
"$date": {
"$numberLong": "1667995992724"
}
}
}]

I am expecting to get only that drawing which is assigned_to : 6
I have tried aggregate, match, project everything but none of them working, it always fetch both of the drawing, but I am expecting to fetch only one drawing 
This what I am expecting
[{
"_id": {
"$oid": "636b9958d6ea5d0cc85d20a6"
},
"project_type": 1,
"title": "Pariatur Aut repreh",
"id": 4,
"drawings": [
{
"id": 1,
"assigned_to": 6,
"assigned_name": "Desirae Sandoval",
"assigned_by": 3
}
],
"status": 1,
"created_at": {
"$date": {
"$numberLong": "1667995992724"
}
}
}]

使用过滤器

db.collection.aggregate([
{
$match: {
"drawings.assigned_to": 6
}
},
{
$project: {
project_type: 1,
title: 1,
id: 1,
status: 1,
created_at: 1,
drawings: {
$filter: {
input: "$drawings",
as: "drawings",
cond: {
$eq: [
"$$drawings.assigned_to",
6
]
}
}
}
}
},

])

编辑:添加一个match来删除所有没有任何文档的文档,其中任何drawings.assigned_to为6