本文介绍了将mongodb聚合框架结果导出到新集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将聚合框架结果保存到新集合中. 我知道目前使用命令本身使用框架是不可能的.
I want to save the aggregation framework result to a new collection. I know that's impossible with the framework at the moment with the command itself.
外壳中是否有解决方法?
Is there a workaround in the shell?
推荐答案更新:请参阅萨尔瓦多的 answer ,以便在MongoDB 2.6+中更有效地做到这一点.
Update: See Salvador's answer for a more efficient way to do this in MongoDB 2.6+.
将聚合结果保存到变量中,然后将其result属性插入新集合中:
Save the aggregation result in a variable and then insert its result property into a new collection:
var result = db.foo.aggregate(...); db.bar.insert(result.result);更多推荐
将mongodb聚合框架结果导出到新集合
发布评论