generated from ctc-uci/npo-backend-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from ctc-uci/10-make-crud-sql-queries-for-publ…
…ished-schedule-table Make CRUD SQL queries for Published Schedule Table
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ?; |