在另一个管道的参数中添加管道阶段 - MongoDB
是否可以将管道添加到MongoDB中其他管道的参数中?
我得到的当前结果的一个例子: mongoplayground
是否可以将EMP表投射到emp表格并将其添加到查找管道之前,作为争论? 我想要的结果:
[
{
"_id": ObjectId("610bce417b0c4008346547bc"),
"employees": [
{
"email": "[email protected]",
"name": "xyz"
}
],
"name": "Chicago",
"number": 10
}
]
Is it possible to add a pipeline to the arguments of another pipeline in mongodb?
An example of the current result that I am getting:
MongoPlayground
Is it possible to project the emp table to only name and email field before adding it to the lookup pipeline as an argument?
The result that I want:
[
{
"_id": ObjectId("610bce417b0c4008346547bc"),
"employees": [
{
"email": "[email protected]",
"name": "xyz"
}
],
"name": "Chicago",
"number": 10
}
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你快到了。您寻求的是
$lookup
的管道版本:它将产生:
You are almost there. What you seek is the pipeline version of
$lookup
:which will yield: