feature #7: Add routes for comment article

This commit is contained in:
2019-08-27 22:24:38 +02:00
parent ff1e34c616
commit 1fb0e39038
12 changed files with 364 additions and 10 deletions

View File

@@ -1,20 +1,17 @@
create or replace function edit_comment(reference regclass, id uuid, content text) returns void
create or replace function edit_comment(reference regclass, _id uuid, _content text) returns void
language plpgsql as
$$
declare
_id alias for id;
_content alias for content;
begin
if reference = 'article'::regclass then
update comment_on_article c set
content = _content
"content" = _content
where c.id = _id;
elseif reference = 'constitution'::regclass then
update comment_on_constitution c set
content = _content
"content" = _content
where c.id = _id;
end if;
end;
$$;
-- drop function if exists edit_comment(regclass, uuid, uuid, text, uuid);
-- drop function if exists edit_comment(regclass, uuid, text);

View File

@@ -9,7 +9,9 @@ begin
from (
select
com.*,
json_build_object('id', com.target_id) as target,
-- TODO use generic object, not article
-- json_build_object('id', com.target_id) as target,
find_article_by_id(com.target_id) as target,
find_citizen_by_id(com.created_by_id) as created_by
from "comment" as com
where id = _id