I have a collection Employee and has the following records in it
{
"id": 1,
"name": "Scott",
"company": "Google"
}
{
"id": 2,
"name": "Steven",
"company": "Yahoo"
}
{
"id": 1,
"name": "Adam",
"company": "Facebook"
}
Any suggestions on what kind of mongodb aggregation pipeline has to be used in order to split the data based on the common field id. For the above example, I would be getting two records as my outcome one which contains key as id 1 with the corresponding list of associated values and the other with the key as 2.