将 mongodb 聚合框架结果导出到新集合

编程入门 行业动态 更新时间:2024-10-25 18:27:38
本文介绍了将 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 聚合框架结果导出到新集合

本文发布于:2023-11-24 09:16:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624627.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:到新   框架   mongodb

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!