hiling_go/db/queries/users.sql

28 lines
495 B
MySQL
Raw Normal View History

2023-09-12 17:07:03 +07:00
-- name: CreateUser :one
2023-09-08 22:24:58 +07:00
INSERT INTO users (
2023-09-12 17:07:03 +07:00
username,
password
) VALUES ($1, $2)
RETURNING *;
-- name: UpdateUser :one
UPDATE users
SET
email = COALESCE(sqlc.narg(email), email),
username = COALESCE(sqlc.narg(username), username),
avatar_picture = COALESCE(sqlc.narg(avatar_picture), avatar_picture)
WHERE
id = sqlc.arg(id)
RETURNING *;
2023-09-21 21:38:41 +07:00
-- name: GetUser :one
SELECT * FROM USERS
WHERE username = $1;
2023-09-12 17:07:03 +07:00
-- name: UpdatePassword :exec
UPDATE users
SET password = $1
WHERE id = $2;