Skip to content

Commit

Permalink
Merge pull request #17 from ctc-uci/10-make-crud-sql-queries-for-publ…
Browse files Browse the repository at this point in the history
…ished-schedule-table

Make CRUD SQL queries for Published Schedule Table
  • Loading branch information
ThatMegamind authored Nov 22, 2023
2 parents fe99a58 + d68a4d2 commit 5ad36f1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions server/queries/published_schedule.sql
Original file line number Diff line number Diff line change
@@ -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 = ?;

0 comments on commit 5ad36f1

Please sign in to comment.