I'm working on a nodejs app and need to join two document arrays together. i have an id field that can be use for joining but am unsure of how to achieve the desired output elegantly. See example arrays below.
array 1
[{"id": 1,
"name": "paul"
},
{"id": 2,
"name": "sarah"
}
]
array 2
[{"id": 1,
"email": "p@test.co.uk"
},
{"id": 2,
"email": "s@test.co.uk"
}
]
output
[{"id": 1,
"name": "paul",
"email": "p@test.co.uk"
},
{"id": 2,
"name": "sarah",
"email": "s@test.co.uk"
}
]