From d68a4d2d9aca89ac725460b773e23b25f53b4d22 Mon Sep 17 00:00:00 2001 From: subinqkim Date: Mon, 20 Nov 2023 15:41:35 -0800 Subject: [PATCH] Made CRUD SQL queries for Published Schedule Table --- server/queries/published_schedule.sql | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 server/queries/published_schedule.sql diff --git a/server/queries/published_schedule.sql b/server/queries/published_schedule.sql new file mode 100644 index 0000000..a730dcb --- /dev/null +++ b/server/queries/published_schedule.sql @@ -0,0 +1,26 @@ +/*GET - Returns all data from the published_schedule table*/ +SELECT * FROM published_schedule; + +/*GET/:id - returns the rows that match the given id*/ +SELECT * FROM published_schedule WHERE 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