Add find_opinions.sql

This commit is contained in:
2020-02-08 01:24:16 +01:00
parent 7742287884
commit 976f8fac6a
3 changed files with 24 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
create or replace function find_opinions(out resource json)
language plpgsql as
$$
begin
select json_agg(t)
into resource
from (
select ol.*
from opinion_list ol
where ol.deleted_at <= now()
or ol.deleted_at is null
order by ol.name
) t;
end;
$$;
-- drop function if exists find_opinions();
-- select find_opinions();