Create find_follow.sql
This commit is contained in:
25
src/main/resources/sql/functions/follow/find_follow.sql
Normal file
25
src/main/resources/sql/functions/follow/find_follow.sql
Normal 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);
|
||||
Reference in New Issue
Block a user