feat: sqlc, nix formatting
This commit is contained in:
46
server/db/queries/user.sql
Normal file
46
server/db/queries/user.sql
Normal file
@ -0,0 +1,46 @@
|
||||
-- name: GetUser :one
|
||||
SELECT
|
||||
id,
|
||||
username,
|
||||
password,
|
||||
profile_picture_id
|
||||
FROM user
|
||||
WHERE
|
||||
id = @id
|
||||
LIMIT 1;
|
||||
|
||||
-- name: GetUserbyUsername :one
|
||||
SELECT
|
||||
id,
|
||||
username,
|
||||
password,
|
||||
profile_picture_id
|
||||
FROM user
|
||||
WHERE
|
||||
username = @username
|
||||
LIMIT 1;
|
||||
|
||||
-- name: InsertUser :one
|
||||
INSERT INTO user (
|
||||
username,
|
||||
password
|
||||
) VALUES (
|
||||
@username,
|
||||
@password
|
||||
)
|
||||
RETURNING id;
|
||||
|
||||
-- name: UpdateUser :exec
|
||||
UPDATE user
|
||||
SET
|
||||
username = COALESCE(sqlc.narg('username'), username),
|
||||
password = COALESCE(sqlc.narg('password'), password),
|
||||
profile_picture_id = COALESCE(
|
||||
sqlc.narg('profile_picture_id'),
|
||||
profile_picture_id
|
||||
)
|
||||
WHERE id = @id;
|
||||
|
||||
-- name: DeleteUser :exec
|
||||
DELETE FROM user
|
||||
WHERE id = @id;
|
Reference in New Issue
Block a user