create function create_new_post("userId" uuid, "title" text, "content" text)
returns boolean
language plpgsql
as $$
begin
with "insertedPost" as (
insert into posts ("user_id", "path") values ($1, 'root')
returning "id"
)
insert into post_contents
("post_id", "title", "content") values
((select "id" from "insertedPost"), $2, $3);
insert into post_score
("post_id", "score") values
((select "id" from "insertedPost"), 0);
commit;
return true;
end; $$
create function create_new_post("userId" uuid, "title" text, "content" text)
returns boolean
language plpgsql
as $$
begin
with "insertedPost" as (
insert into posts ("user_id", "path") values ($1, 'root')
returning "id"
)
insert into post_contents
("post_id", "title", "content") values
((select "id" from "insertedPost"), $2, $3);
insert into post_score
("post_id", "score") values
((select "id" from "insertedPost"), 0);
commit;
return true;
end; $$