Create OpinionChoice
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
create or replace function find_opinion_choice_by_id(_id uuid, out resource json)
|
||||
language plpgsql as
|
||||
$$
|
||||
begin
|
||||
select to_json(ol) into resource
|
||||
from opinion_list ol
|
||||
where (ol.deleted_at <= now()
|
||||
or ol.deleted_at is null)
|
||||
and (ol.id = _id);
|
||||
end;
|
||||
$$;
|
||||
|
||||
-- drop function if exists find_opinion_choice_by_id();
|
||||
|
||||
-- select find_opinion_choice_by_id('8c6cb3cc-cac5-93ad-312e-6bd87d9916d9');
|
||||
@@ -1,4 +1,4 @@
|
||||
create or replace function find_opinions(out resource json)
|
||||
create or replace function find_opinion_choices(targets text[] default null, out resource json)
|
||||
language plpgsql as
|
||||
$$
|
||||
begin
|
||||
@@ -7,8 +7,10 @@ begin
|
||||
from (
|
||||
select ol.*
|
||||
from opinion_list ol
|
||||
where ol.deleted_at <= now()
|
||||
or ol.deleted_at is null
|
||||
where (ol.deleted_at <= now()
|
||||
or ol.deleted_at is null)
|
||||
and (ol.target is null or array_length(targets) = 0 or ol.target = any(targets))
|
||||
|
||||
order by ol.name
|
||||
) t;
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user