本文介绍了将 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.
shell 中有解决方法吗?
Is there a workaround in the shell?
推荐答案更新:参见 Salvador 的 答案 用于在 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 聚合框架结果导出到新集合
发布评论