feat: database method to move wish to another list
This commit is contained in:
@@ -435,4 +435,23 @@ SET
|
||||
deleted = COALESCE(@deleted::boolean, w.deleted)
|
||||
WHERE w.guid = (@guid::text)::uuid;
|
||||
|
||||
;-- name: MoveWishToWishListWithGuid :one
|
||||
WITH updated AS (
|
||||
UPDATE wishes w
|
||||
SET
|
||||
wish_list_id = wl.id,
|
||||
wish_list_guid = (@wish_list_guid::text)::uuid
|
||||
FROM wish_lists wl
|
||||
WHERE
|
||||
wl.guid = (@wish_list_guid::text)::uuid AND
|
||||
wl.profile_id = ( -- Make sure the wish is not moved to another profile
|
||||
SELECT profile_id
|
||||
FROM wish_lists
|
||||
WHERE wish_lists.id = w.wish_list_id
|
||||
)
|
||||
RETURNING w.id
|
||||
)
|
||||
SELECT
|
||||
COUNT(*) > 0 AS target_found
|
||||
FROM updated;
|
||||
--: }}}
|
||||
|
||||
Reference in New Issue
Block a user