I'm struggling to solve a seemingly simple issue. I have an array that looks like this:
Array 1:[
{
"id": 1,
"date": "2019-03-27",
"time": 1,
"max_tasks": 3,
"reservations": [
5,
2
]
},
...
]
Within the reservations
property of Array 1, there are IDs that correspond to another array shown below:
[
{
"id": 5,
"app": 1,
"comment": "test 5"
},
...
]
Expected Outcome:
I need to merge the data from Array 2 into Array 1 based on matching IDs in both arrays. The desired result is to return Array 1 with the objects added from Array 2.
I am using Vue.js and would like to achieve this through computed properties or getters in order to directly access the updated array in my component. Any alternative methods to accomplish this task are welcome.
This is the output format I aim to achieve:
[
{
'id': 1,
'date': '2019-03-27',
'time': 1,
'max_tasks': 3,
'reservations': [
{
'id': 5,
'app': 1,
'comment': 'test 5'
},
...
]
},
...
]
Thank you for your assistance.