I messed with it for hours
What is the best way to manipulate/convert this array of objects:
const arr = [
{
_id: "5fb70c9244fa59c7dc1d9151",
date: "2020-11-22T09:00:00.000Z",
determinedBy: {
_id: "man1",
name: "manA",
},
hour: "10:00",
massageType: "mass",
},
{
_id: "2",
date: "2020-11-22T09:00:00.000Z",
determinedBy: {
_id: "man2",
name: "manB",
},
hour: "11:00",
massageType: "thay",
},
{
_id: "3",
date: "2020-12-05T09:00:00.000Z",
determinedBy: {
_id: "man3",
name: "manC",
},
hour: "20:00",
massageType: "chi",
},
to this structure:
const objManipulate={
2020-11-22T09:00:00.000Z:[
{
_id: "5fb70c9244fa59c7dc1d9151",
determinedBy: {
_id: "5fac1f65a9e40443ccdf274b",
name: "a",
},
hour: "10:00",
massageType: "mass",
},
{
_id: "2",
date: "2020-11-22T09:00:00.000Z",
determinedBy: {
_id: "2222222",
name: "sssssa",
},
hour: "11:00",
massageType: "thay",
}
]
"2020-12-05T09:00:00.000Z:[
{
_id: "3",
determinedBy: {
_id: "3333333",
name: "threee",
},
hour: "20:00",
massageType: "chi",
},
]
as u see:
- key - > its by date day (the hour doesn't matter, I will convert the date after to showing MM/DD/YYYY, no problem with this)
- value -> array of objects of all meetings in this day.
-I need this to show the data in the react-native-calendar in right way, note that I tried with a for loop, map, filter, but that didn't work.