1
I am developing a Web Services REST application with Spring Boot and need to group the goals by players in order to show the scorers from the following records:
[
  {
    "id": 1,
    "adversario": "Dois irmãos",
    "dataRealizacao": "2017-02-03",
    "golsPro": 10,
    "golsContra": 3,
    "jogadoresGols": [
      {
        "jogador": {
          "nome": "Murillo"
        },
        "numeroGols": 6
      },
      {
        "jogador": {
          "nome": "Eduardo"
        },
        "numeroGols": 4
      }
    ]
  },
  {
    "id": 2,
    "adversario": "Amigos Greminho",
    "dataRealizacao": "2017-02-13",
    "golsPro": 17,
    "golsContra": 1,
    "jogadoresGols": [
      {
        "jogador": {
          "nome": "Murillo"
        },
        "numeroGols": 12
      },
      {
        "jogador": {
          "nome": "Eduardo"
        },
        "numeroGols": 5
      }
    ]
  }
]
I wish to obtain the following output:
[
   {
      "jogador": {
         "nome": "Murillo"
      },
      "totalGols": 18
   },
   {
      "jogador": {
         "nome": "Eduardo"
      },
      "totalGols": 9
   }
]
I think you should iterate the query result in the application: filtering by name and incrementing the results (goals)
– Lauro Moraes
Like this: http://docs.spring.io/spring-data/data-mongo/docs/current/reference/html/#Mongo.group
– Bruno César