diff --git a/routes/catalog.js b/routes/catalog.js index f3c18a5..98a5a35 100644 --- a/routes/catalog.js +++ b/routes/catalog.js @@ -95,10 +95,11 @@ catalogRouter.get('/:id', async (req, res) => { // -- POST - Adds a new row to the catalog table catalogRouter.post('/', async (req, res) => { const { host, title, eventType, subject, description, year, season, location } = req.body; + try { const returnedData = await db.query( - `INSERT INTO catalog (id, host, title, event_type, subject, description, year, season, location) - VALUES (nextval('catalog_id_seq'), $1, $2, $3, $4, $5, $6, $7, $8) + `INSERT INTO catalog (id, host, title, event_type, subject, description, year, season, location, hidden) + VALUES (nextval('catalog_id_seq'), $1, $2, $3::event[], $4::subject[], $5, $6::year[], $7::season[], $8, false) RETURNING id;`, [host, title, eventType, subject, description, year, season, location], ); diff --git a/server/schema/catalog.sql b/server/schema/catalog.sql index c3096a2..2a3b598 100644 --- a/server/schema/catalog.sql +++ b/server/schema/catalog.sql @@ -8,10 +8,11 @@ CREATE TABLE catalog ( id SERIAL PRIMARY KEY, host VARCHAR(50) NOT NULL, title VARCHAR(50) NOT NULL, - event_type event NOT NULL, - subject subject NOT NULL, + event_type event[] NOT NULL, + subject subject[] NOT NULL, description VARCHAR(50) NOT NULL, - year year NOT NULL, - season season, - location VARCHAR(256) + year year[] NOT NULL, + season season[], + location VARCHAR(256), + hidden BOOLEAN NOT NULL, );