-
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.
Signed-off-by: Eduardo Morales <[email protected]>
- Loading branch information
Showing
4 changed files
with
286 additions
and
24 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
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,56 @@ | ||
-- CreateSet: returns a new set, providing: | ||
-- a exercise id, and reps and weights | ||
-- | ||
-- returns: the new set row | ||
-- name: CreateSet :one | ||
INSERT INTO "set" ( | ||
exercise_id, reps, weight | ||
) VALUES ( | ||
(SELECT "workouts".id FROM "workouts" WHERE "workouts".id = $1), $2, $3 | ||
) RETURNING *; | ||
|
||
-- GetExerciseSets: returns all exercises sets | ||
-- | ||
-- returns: the exercises corresponding sets | ||
-- name: GetExerciseSets :many | ||
SELECT * FROM "set" | ||
WHERE exercise_id = $1; | ||
|
||
-- GetSet: returns an existing Set, given Set id | ||
-- | ||
-- returns: the corresponding Set row | ||
-- name: GetSet :one | ||
SELECT * FROM "set" | ||
WHERE id = $1 LIMIT 1; | ||
|
||
-- UpdateSetRep: updates sets reps given its id | ||
-- | ||
-- returns: the set's new corresponding row | ||
-- name: UpdateSetRep :one | ||
UPDATE "set" | ||
SET reps = $2 | ||
WHERE id = $1 | ||
RETURNING *; | ||
|
||
-- UpdateSetWeight: updates set's weight given its id | ||
-- | ||
-- returns: the sets's new corresponding row | ||
-- name: UpdateSetWeight :one | ||
UPDATE "set" | ||
SET weight = $2 | ||
WHERE id = $1 | ||
RETURNING *; | ||
|
||
-- DeleteSingleSet: deletes a single exercises's set | ||
-- | ||
-- returns: nothing! see https://docs.sqlc.dev/en/stable/reference/query-annotations.html for exec | ||
-- name: DeleteSingleSet :exec | ||
DELETE FROM "set" | ||
WHERE id = $1; | ||
|
||
-- DeleteAllSets: deletes All exercises sets! | ||
-- | ||
-- returns: nothing! see https://docs.sqlc.dev/en/stable/reference/query-annotations.html for exec | ||
-- name: DeleteAllSets :exec | ||
DELETE FROM "set" | ||
WHERE exercise_id = $1; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.