Js array object add field problem

data fetched from the background
[

{
    date: "12-01",
    name: "a",
    rank: "111"
},
{
    date: "12-01",
    name: "b",
    rank: "112"
},
{
    date: "12-02",
    name: "c",
    rank: "100"
},
{
    date: "12-04",
    name: "a",
    rank: "104"
},
{
    date: "12-04",
    name: "b",
    rank: "112"
}

]

there are duplicates and vacancies. I would like to fill in all the dates of the vacancy, such as the following:
if rank does not have data, fill in "-"
[

"
{
    date: "12-01",
    name: "a",
    rank: "111"
},
{
    date: "12-01",
    name: "b",
    rank: "112"
},
{
    date: "12-01",
    name: "c",
    rank: "-"
},
{
    date: "12-02",
    name: "a",
    rank: "-"
},
{
    date: "12-02",
    name: "b",
    rank: "-"
},
{
    date: "12-02",
    name: "c",
    rank: "100"
},
{
    date: "12-04",
    name: "a",
    rank: "104"
},
{
    date: "12-04",
    name: "b",
    rank: "112"
},
{
    date: "12-04",
    name: "c",
    rank: "105"
}

]
what should I do with this?

May.21,2022

data.map((item)=>({'date': item.date, 'name': item.name, 'rank': item.rank || '-'}))

origin the data returned in the background can be processed by the following complete function

const complete = (origin) => {
    const dict = {}
    //dict
    origin.forEach(o => {
        if(!dict[o.date]){
            dict[o.date] = {}
        }
        dict[o.date][o.name]=o.rank
    })
    const target = []
    //
    for (let day in dict) {
        ['a','b', 'c'].forEach(name => target.push({
            date: day,
            name,
            rank: dict[day][name] || '--'
        }))
    }
    return target
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eaf3eb-47ff5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eaf3eb-47ff5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?