My goal is to have nested data organized by the day number.
Here is an array example that I want to group using the lodash plugin.
[{
"Pnl": 29.0035635,
"date": ""11/14/2022",
"dayNumber"" : 1,
"translationDayOfWeek": "Monday"
},
{
"Pnl": 50.8878545,
"date": "11/08/2022",
"dayNumber"" : 2,
"translationDayOfWeek": "Tuesday"
},
{
"Pnl": 73.1014552,
"date": "11/08/2022",
"dayNumber" : 2,
"translationDayOfWeek": "Tuesday"
},
{
"Pnl": 32.477,
"date": "11/08/2022",
"dayNumber : 6,
"translationDayOfWeek":"Saturday"
},
{
"Pnl"": 25.43999561,
"date": ""09/30/2022",
"dayNumber"": 5,
"translationDayOfWeek": ""Friday"
},
{
"Pnl"": 17.6294068,
"date": ""09/30/2022",
"dayNumber ": 1,
"translationDayOfWeek"" : "Monday"
}]
This is what I expect for an output:
[
{
"dayNumber": 1,
"orders":[
{
"Pnl": 29.0035635,
"date": "11/14/2022",
"dayNumber": 1,
"translationDayOfWeek": "Monday"
},
{
"Pnl": 17.6294068,
"date": "09/30/2022",
"dayNumber": 1,
"translationDayOfWeek": "Monday"
}
]
},
{
"dayNumber": 2,
"orders": [
{
"Pnl": 50.8878545,
"date": "11/08/2022",
"dayNumber": 2,
"translationDayOfWeek": "Tuesday"
},
{
"Pnl": 73.1014552,
"date": "11/08/2022",
"dayNumber": 2,
"translationDayOfWeek": "Tuesday"
}
]
}
]
I attempted the solutions provided in a Stack Overflow post, but it did not yield the desired result for me.