Code Optimization on data manipulation

there are many service stations under the city that need the data of linkage effect
all the servers are returned to me. My code is as follows, how to optimize

export const dealDistribution = (data) => {
  const treeData = []
  data.forEach(item => {
    const isExit = treeData.find(treeItem => treeItem.cityCode === item.cityCode)
    if (!isExit) {
      treeData.push({
        cityCode: item.cityCode,
        cityName: item.cityName,
        pickhouseList: []
      })
    }
  })
  treeData.map(treeItem => {
    data.map(dataItem => {
      if (treeItem.cityCode === dataItem.cityCode) {
        treeItem.pickhouseList.push({
          pickhouseId: dataItem.id,
          pickhouseName: dataItem.name
        })
      }
    })
  })
  return treeData
}
Apr.26,2022

I think it's the problem of database design

1, city data

[
    {
        "cityName": xxx,
        "cityCode": xxx,
    },
    {
        "cityName": xxx,
        "cityCode": xxx,
    },
]

Select the city, and then request the subordinate service station from the server.

2. Data of service stations under the city

the server looks for subordinate service stations according to cityCode .

{
     "cityName": xxx,
     "cityCode": xxx,
     "sub": [
            {
                "name": xxx,
                "code": xxx
            }
     ]
}
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-1b3eed9-2b99c.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-1b3eed9-2b99c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?