feat: query for update usertitle
This commit is contained in:
parent
f2589e05e8
commit
658d666fec
3 changed files with 49 additions and 19 deletions
|
|
@ -461,21 +461,13 @@ VALUES (
|
|||
)
|
||||
RETURNING user_id, title_id, status, rate, review_id, ctime;
|
||||
|
||||
-- -- name: UpdateUserTitle :one
|
||||
-- UPDATE usertitles
|
||||
-- SET
|
||||
-- status = COALESCE(sqlc.narg('status'), status),
|
||||
-- rate = COALESCE(sqlc.narg('rate'), rate),
|
||||
-- review_id = COALESCE(sqlc.narg('review_id'), review_id)
|
||||
-- WHERE user_id = $1 AND title_id = $2
|
||||
-- RETURNING *;
|
||||
|
||||
-- -- name: DeleteUserTitle :exec
|
||||
-- DELETE FROM usertitles
|
||||
-- WHERE user_id = $1 AND ($2::int IS NULL OR title_id = $2);
|
||||
|
||||
-- -- name: ListTags :many
|
||||
-- SELECT tag_id, tag_names
|
||||
-- FROM tags
|
||||
-- ORDER BY tag_id
|
||||
-- LIMIT $1 OFFSET $2;
|
||||
-- name: UpdateUserTitle :one
|
||||
-- Fails with sql.ErrNoRows if (user_id, title_id) not found
|
||||
UPDATE usertitles
|
||||
SET
|
||||
status = COALESCE(sqlc.narg('status')::usertitle_status_t, status),
|
||||
rate = COALESCE(sqlc.narg('rate')::int, rate)
|
||||
WHERE
|
||||
user_id = sqlc.arg('user_id')
|
||||
AND title_id = sqlc.arg('title_id')
|
||||
RETURNING *;
|
||||
Loading…
Add table
Add a link
Reference in a new issue