I managed to create a query to get some data from the database using the following script:
app.get("/diseases", async (req, res) => {
const rows = await process.postgresql.query(
"SELECT ds.disease, ds.symptom FROM diseases ds"
);
console.log(rows);
res.status(200).send(JSON.stringify(rows));
});
The data comes in the following format:
[
{ disease: ' boală hipertensivă', symptom: ' durere toracică' },
{
disease: ' boală hipertensivă',
symptom: ' respirație întretăiată'
},
{ disease: ' boală hipertensivă', symptom: ' amețeală' },
{ disease: ' boală hipertensivă', symptom: ' astenie' },
{ disease: ' boală hipertensivă', symptom: ' toamnă (Fall)' },
{ disease: ' boală hipertensivă', symptom: ' sincopă' },
{ disease: ' diabet', symptom: ' poliurie' }
]
My question is how to transform this data in a format, like the following:
{"Hypertensive disease": ["Pain chest", "Shortness of breath", "Dizziness", "Asthenia", "Fall", "Syncope", "Vertigo", "Sweat", "Sweating increased", "Palpitation", "Nausea", "Angina pectoris", "Pressure chest"], "Diabetes": ["Polyuria"]}