From 7e4137f908acbdb5e402889d93b276534bdf91b7 Mon Sep 17 00:00:00 2001 From: visionthex Date: Mon, 12 Feb 2024 16:40:47 -0500 Subject: [PATCH] database uploading properly --- app/src/components/DatabaseFetch.js | 3 ++- server/migrations/20240211072255_create_tbl_scan.js | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/components/DatabaseFetch.js b/app/src/components/DatabaseFetch.js index e8108ef5..754f499a 100644 --- a/app/src/components/DatabaseFetch.js +++ b/app/src/components/DatabaseFetch.js @@ -36,7 +36,8 @@ function DataFetchComponent() { setIsLoading(true); try { const response = await axios.get('http://localhost:4000/api/analysis_results'); - setData(response.data); + const dataWithIds = response.data.map((item, index) => ({ ...item, id: index })); + setData(dataWithIds); } catch (error) { console.error("Error fetching data:", error); setError('Error fetching data'); diff --git a/server/migrations/20240211072255_create_tbl_scan.js b/server/migrations/20240211072255_create_tbl_scan.js index ed13e2e5..27ff7bb9 100644 --- a/server/migrations/20240211072255_create_tbl_scan.js +++ b/server/migrations/20240211072255_create_tbl_scan.js @@ -1,12 +1,13 @@ exports.up = function(knex) { return knex.schema.createTable('csv_scan', function(table) { table.increments('id').primary(); - table.text('data'); - table.string('f/p'); - table.string('module'); - table.string('scanName'); - table.string('source'); - table.string('type'); + table.text('Scan Name'); + table.text('Updated'); + table.text('Type'); + table.text('Module'); + table.text('Source'); + table.text('F/P'); + table.text('Data', 'longtext'); }); };