【问题标题】:MongoError: The 'cursor' option is required, except for aggregate with the explain argumentMongoError: 'cursor' 选项是必需的,除了带有解释参数的聚合
【发布时间】:2018-10-10 14:00:38
【问题描述】:

即使出现以下错误,我仍在使用最新版本的 mongodb 3.6...

MongoError: The 'cursor' option is required, except for aggregate with the explain argument

const user = await User.aggregate([
      { $group: {
          _id: '$_id',
          domain: { $push: "$domain" },
          domain: { $push: "$email" },
          domain: { $push: "$userName" }
        }
      }
    ])

【问题讨论】:

  • 更新猫鼬。 5.0 之前的 Mongoose 版本与 MongoDB 3.6 不匹配。 MongoDB 3.6 将聚合 API 从“游标可选”更改为“仅游标”,旧 mongoose 版本通过尝试调用不推荐的方式来请求数组作为响应来打破这一点。

标签: node.js mongodb mongoose mongodb-query aggregation-framework


【解决方案1】:

感谢@Neil Lunn

更新猫鼬。 5.0 之前的 Mongoose 版本与 MongoDB 3.6 不匹配。 MongoDB 3.6 将聚合 API 从“游标可选”更改为“仅游标”,旧 mongoose 版本通过尝试调用已弃用的方式来请求数组作为响应来打破这一点。

【讨论】:

    猜你喜欢
    • 2019-11-29
    • 1970-01-01
    • 1970-01-01
    • 2018-07-07
    • 2019-05-09
    • 1970-01-01
    • 2017-10-12
    • 2022-01-09
    • 1970-01-01
    相关资源
    最近更新 更多