Mongo 2.6.1-无法识别的管道阶段名称:"$ out" [英] Mongo 2.6.1 - Unrecognized pipeline stage name: '$out'

查看:71
本文介绍了Mongo 2.6.1-无法识别的管道阶段名称:"$ out"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Mongo集合,我需要将一组对象移动到一个单独的集合中.

I have a Mongo collection where I need to move an array of objects into a separate collection.

该集合的格式如下:

{
    _id: ObjectId("..."),
    name: "...",
    description: "...",
    widgets: [
       { someprop: somevalue },
       { someprop: somevalue }
    ]
}

我想将对象数组展开为一个单独的集合.

I'd like to unwind the object array into a separate collection.

根据$ out的文档,网址为 http://docs.mongodb .org/manual/reference/operator/aggregation/out/我应该能够使用运算符来创建新集合.

According to the documentation for $out at http://docs.mongodb.org/manual/reference/operator/aggregation/out/ I should be able to use the operator to create a new collection.

以下Mongo shell命令中的前两个操作可将数组展开到列表中,但是当我添加$ out操作时失败:

The first two operations in the following Mongo shell command work to unwind the array into a list but it fails when I add the $out operation:

db.mytable.aggregate([
    { $project : {_id: 0, datasets : 1}},
    { $unwind : "$widgets"}, 
    { $out: "widgets"}
]);

错误:

Error: command failed: {
"errmsg" : "exception: Unrecognized pipeline stage name: '$out'",
"code" : 16436,
"ok" : 0
} : aggregate failed at src/mongo/shell/assert.js:13

推荐答案

确保您使用的是最新版本. $ out是2.6中的新功能,使用2.6.2对我来说是完美的选择!

Make sure you're using the latest version. $out is new in 2.6, using 2.6.2 worked perfectly for me !

这篇关于Mongo 2.6.1-无法识别的管道阶段名称:"$ out"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆