Thursday, 11 May 2017

how to group records based on dates in mongodb

How to group data by dates? I have some docs in mongo that looks something like this:

[
    {
      "date": "2017/2/9",
      "points": -1
    }
  ],
  [
    {
      "date": "2017/2/9",
      "points": 1
    },
    {
      "date": "2017/2/10",
      "points": -1
    },
    {
      "date": "2017/2/11",
      "points": -1
    }
  ],
  [
    {
      "date": "2017/2/9",
      "points": 1
    },
    {
      "date": "2017/2/10",
      "points": 1
    },
    {
      "date": "2017/2/11",
      "points": -1
    }
  ]

I'd like to be able to count the no of points by date



via Schüler

No comments:

Post a Comment