Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The Field "$_id" must be an accumulator object

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.

like image 269
ffritz Avatar asked May 18 '17 08:05

ffritz


1 Answers

$_id is not an accumulator function it should be _id

like image 182
user3317755 Avatar answered Oct 17 '22 21:10

user3317755