feature #4: add relations to upsert_article
This commit is contained in:
@@ -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;
|
||||
$$;
|
||||
|
||||
Reference in New Issue
Block a user