对于我使用的请求aggregate
,我通过的地方:
[{
$match: {
id
}
},
{
$lookup: {
from: 'blogs',
as: 'blog',
pipeline: [{
$project: {
id: 1,
name: 1,
articles: 1
},
}, {
$match: {
articles: {
$in: [id]
}
}
}]
}
}
]
wherearticles
是一个长度不定的数组。我指向articles
以便$project
我以后可以使用它$match
。问题是最后,它与文档一起返回给我articles
,这是服务器上的额外负载。你怎么能不返回收到的字段$project
?
结果,平庸帮助了我
$unset
:也许有更好的解决方案。