Create find_follow.sql

This commit is contained in:
2020-02-27 17:12:32 +01:00
parent 1418dd95bc
commit 3a08052728
9 changed files with 138 additions and 5 deletions

View File

@@ -0,0 +1,25 @@
create or replace function find_follow(
_target_id uuid,
_citizen_id uuid,
out resource json,
out following boolean
) language plpgsql as
$$
begin
select to_json(t)
into resource
from (
select
f.*,
json_build_object('id', f.target_id, 'reference', f.target_reference) as target,
find_citizen_by_id(f.created_by_id) as created_by
from follow as f
where f.created_by_id = _citizen_id
and f.target_id = _target_id
) as t;
select resource is not null into following;
end;
$$;
-- drop function if exists find_follow(uuid, uuid);