a tool for shared writing and social publishing
at feature/analytics 24 lines 518 B view raw
1CREATE OR REPLACE FUNCTION public.get_facts(root uuid) 2 RETURNS SETOF facts 3 LANGUAGE sql 4AS $function$WITH RECURSIVE all_facts as ( 5 select 6 * 7 from 8 facts 9 where 10 entity = root 11 union 12 select 13 f.* 14 from 15 facts f 16 inner join all_facts f1 on ( 17 uuid(f1.data ->> 'value') = f.entity 18 ) where f1.data ->> 'type' = 'reference' or f1.data ->> 'type' = 'ordered-reference' or f1.data ->> 'type' = 'spatial-reference' 19 ) 20select 21 * 22from 23 all_facts;$function$ 24;