Mongodb$lookup将集合合并到新集合中
首先,我是mongodb新手,所以我的问题可能很愚蠢 我有两个集合,我使用Mongodb$lookup将集合合并到新集合中,mongodb,mongodb-query,aggregation-framework,Mongodb,Mongodb Query,Aggregation Framework,首先,我是mongodb新手,所以我的问题可能很愚蠢 我有两个集合,我使用$lookup db.information.aggregate([ { $lookup: { from: "extra_info", localField: "identification", foreignField: "identification",
$lookup
db.information.aggregate([
{
$lookup: {
from: "extra_info",
localField: "identification",
foreignField: "identification",
as: "extra_info"
}
}
])
作为输出,我得到了我想要的“集合”,但它没有存储在
db.information
集合
有什么能让这一切发生的暗示吗 使用聚合管道将聚合数据保存到新集合:
db.information.aggregate([
{
$lookup: {
from: "extra_info",
localField: "identification",
foreignField: "identification",
as: "extra_info"
}
},
{
$out : "newcollection" // name of the collection to save the lookup in
}
])
我真的不知道该怎么办,任何帮助都将非常感激谢谢你的回答!我这样做了,但得到的输出如下:WriteResult({“nInserted”:1})。添加新的奇怪条目,但不修改文档