The Field “$_id” must be an accumulator object

旧巷老猫 提交于 2019-12-23 08:48:16

问题


I am trying to group some documents within mongoDB, right after a $match stage like this:

db.trips.aggregate([
  { "$match": {
      "Stop Time": {
        "$lt": "31.07.2013 23:59"
      }
    }
  },
    {   "$group": {
          "$_id": { "Start": "$Start", "End": "$End" },
    }
  }]

However I am getting the following error:

"The field '$_id' must be an accumulator object"

Why does this error show up, and why does it only show up when I include the match stage? Without the match stage, it works just fine.


回答1:


$_id is not an accumulator function it should be _id



来源:https://stackoverflow.com/questions/44042329/the-field-id-must-be-an-accumulator-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!