Good evening, I need to group an array of objects by their nickname, here I show you the data:
[
  {
    "nickName": "Info2",
    "countNotice": 4
  },
  {
    "nickName": "Info2",
    "countAlarm": 1
  }, 
  {
    "nickName": "Info1",
    "countNotice": 2
  },
  {
    "nickName": "Info1",
    "countAlarm": 3
  }
]
here I show you the expected result:
[{
  "nickName": "Info1",
  "countNotice": 2,
  "countAlarm": 3
},
{
  "nickName": "Info1",
  "countAlarm": 1,
  "countNotice": 4
}]
I tried aggregate from MongoDB in NodeJs but it was impossible.
                        
You could group and then merge each grouped
Live example