diff --git a/routes/publishedSchedule.js b/routes/publishedSchedule.js index 8b7411d..2120758 100644 --- a/routes/publishedSchedule.js +++ b/routes/publishedSchedule.js @@ -98,7 +98,6 @@ publishedScheduleRouter.post('/', async (req, res) => { // PUT/:id - Updates an existing row given an id publishedScheduleRouter.put('/:id', async (req, res) => { - try { const { id } = req.params; const { @@ -132,7 +131,7 @@ publishedScheduleRouter.put('/:id', async (req, res) => { }); // DELETE/:id - deletes an existing row given an id -publishedScheduleRouter.put('/id', async (req, res) => { +publishedScheduleRouter.delete('/:id', async (req, res) => { try { const { id } = req.params; await db.query( @@ -140,7 +139,7 @@ publishedScheduleRouter.put('/id', async (req, res) => { DELETE FROM published_schedule WHERE id = $1; `, - [id] + [id], ); res.status(200).send('Deleted row from Published Schedule'); } catch (err) { diff --git a/server/queries/published_schedule.sql b/server/queries/published_schedule.sql deleted file mode 100644 index 6908fce..0000000 --- a/server/queries/published_schedule.sql +++ /dev/null @@ -1,51 +0,0 @@ -/*GET - Returns all data from the published_schedule table*/ -SELECT - PS.id, - C.host, - C.title, - PS.confirmed, - PS.confirmed_on, - PS.start_time, - PS.end_time, - PS.cohort, - PS.notes -FROM - published_schedule PS - LEFT JOIN catalog C ON PS.event_id = C.id; - -/*GET/:id - returns the rows that match the given id*/ -SELECT - PS.id, - C.host, - C.title, - PS.confirmed, - PS.confirmed_on, - PS.start_time, - PS.end_time, - PS.cohort, - PS.notes -FROM - published_schedule PS - LEFT JOIN catalog C ON PS.event_id = C.id - AND PS.id = ?; - -/*POST - Adds a new row to the published_schedule table -Note: Confirmed should be defaulted to true*/ -INSERT INTO published_schedule (id, event_id, confirmed, confirmed_on, start_time, end_time, cohort, notes) -VALUES (?, ?, true, ?, ?, ?, ?, ?); - -/*PUT - Updates an existing row given an id -Notes: All fields are optional*/ -UPDATE published_schedule -SET - event_id = COALESCE(?, event_id), - confirmed = COALESCE(?, confirmed), - confirmed_on = COALESCE(?, confirmed_on), - start_time = COALESCE(?, start_time), - end_time = COALESCE(?, end_time), - cohort = COALESCE(?, cohort), - notes = COALESCE(?, notes) -WHERE id = ?; - -/*DELETE - deletes an existing row given an id*/ -DELETE FROM published_schedule WHERE id = ?; \ No newline at end of file