feature #4: add relations to upsert_article

This commit is contained in:
2019-07-29 14:06:57 +02:00
parent 84276ad496
commit 6cd539d697

View File

@@ -16,6 +16,15 @@ begin
from json_populate_record(null::article, resource)
returning id into new_id;
if resource->>'relations' is not null then
insert into article_relations (source_id, target_id, created_by_id)
select
(resource->>'id')::uuid,
id,
(resource#>>'{created_by, id}')::uuid
from json_populate_recordset(null::article, resource->>'relations');
end if;
select find_article_by_id(new_id) into resource;
end;
$$;