pronounss/backend/db/queries/queries.member.sql
2023-01-04 22:41:29 +01:00

31 lines
804 B
SQL

-- name: GetMemberByID :one
SELECT * FROM members
WHERE id = pggen.arg('id');
-- name: GetMemberByName :one
SELECT * FROM members
WHERE user_id = pggen.arg('user_id') AND (
id = pggen.arg('member_ref')
OR name = pggen.arg('member_ref')
);
-- name: GetMembers :many
SELECT * FROM members
WHERE user_id = pggen.arg('user_id')
ORDER BY name, id;
-- name: UpdateMemberNamesPronouns :one
UPDATE members SET
names = pggen.arg('names'),
pronouns = pggen.arg('pronouns')
WHERE id = pggen.arg('id')
RETURNING *;
-- name: GetMemberFields :many
SELECT * FROM member_fields WHERE member_id = pggen.arg('member_id') ORDER BY id ASC;
-- name: InsertMemberField :one
INSERT INTO member_fields
(member_id, name, entries) VALUES
(pggen.arg('member_id'), pggen.arg('name'), pggen.arg('entries'))
RETURNING *;