Skip to content

Commit

Permalink
accommodating for the multi select fields in the catalog form
Browse files Browse the repository at this point in the history
  • Loading branch information
lanaramadan committed Mar 20, 2024
1 parent 2087426 commit e0784e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions routes/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
);
Expand Down
11 changes: 6 additions & 5 deletions server/schema/catalog.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);

0 comments on commit e0784e9

Please sign in to comment.