Skip to content
This repository has been archived by the owner on Apr 21, 2024. It is now read-only.

Commit

Permalink
refactor: organise queries
Browse files Browse the repository at this point in the history
  • Loading branch information
GetPsyched committed Oct 10, 2023
1 parent 7dc9b6f commit 966ee3f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 56 deletions.
56 changes: 0 additions & 56 deletions database/queries/club.sql → database/queries/club/default.sql
Original file line number Diff line number Diff line change
@@ -1,32 +1,3 @@
-- name: CreateClubFaculty :exec
INSERT INTO club_faculty (
club_name, emp_id
)
VALUES (
@club_name, @emp_id
);

-- name: CreateClubSocial :exec
INSERT INTO club_social (
club_name, platform_type, link
)
VALUES (
@club_name, @platform_type, @link
);

-- name: DeleteClubFaculty :exec
DELETE FROM
club_faculty AS cf
WHERE
cf.club_name = @club_name
AND cf.emp_id = @emp_id;

-- name: DeleteClubSocial :exec
DELETE FROM club_social
WHERE
club_name = @club_name
AND platform_type = @platform_type;

-- name: GetClub :one
SELECT
club.name,
Expand Down Expand Up @@ -95,30 +66,3 @@ FROM
club
ORDER BY
club.name;

-- name: GetClubFaculty :many
SELECT
f.name, f.mobile
FROM
faculty AS f
JOIN club_faculty AS cf ON f.emp_id = cf.emp_id
WHERE
cf.club_name = @club_name;

-- name: GetClubSocials :many
SELECT
platform_type,
link
FROM
club_social
WHERE
club_name = @club_name;

-- name: UpdateClubSocials :exec
UPDATE
club_social
SET
link = @link
WHERE
platform_type = @platform_type
AND club_name = @club_name;
23 changes: 23 additions & 0 deletions database/queries/club/faculty.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- name: CreateClubFaculty :exec
INSERT INTO club_faculty (
club_name, emp_id
)
VALUES (
@club_name, @emp_id
);

-- name: GetClubFaculty :many
SELECT
f.name, f.mobile
FROM
faculty AS f
JOIN club_faculty AS cf ON f.emp_id = cf.emp_id
WHERE
cf.club_name = @club_name;

-- name: DeleteClubFaculty :exec
DELETE FROM
club_faculty AS cf
WHERE
cf.club_name = @club_name
AND cf.emp_id = @emp_id;
31 changes: 31 additions & 0 deletions database/queries/club/social.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-- name: CreateClubSocial :exec
INSERT INTO club_social (
club_name, platform_type, link
)
VALUES (
@club_name, @platform_type, @link
);

-- name: GetClubSocials :many
SELECT
platform_type,
link
FROM
club_social
WHERE
club_name = @club_name;

-- name: UpdateClubSocials :exec
UPDATE
club_social
SET
link = @link
WHERE
platform_type = @platform_type
AND club_name = @club_name;

-- name: DeleteClubSocial :exec
DELETE FROM club_social
WHERE
club_name = @club_name
AND platform_type = @platform_type;

0 comments on commit 966ee3f

Please sign in to comment.