create or REPLACE FUNCTION private.db_pre_request () returns void language plpgsql stable security definer
set search_path = public as $function$
declare groups jsonb;
begin -- get current groups from auth.users
select raw_app_meta_data->'groups'
from auth.users into groups
where id = auth.uid();
-- store it in the request object
perform set_config(
'request.groups'::text,
groups::text,
false
/* applies to transaction if true, session if false */
);
end;
$function$;
grant usage on schema private to authenticated,
postgres;
create or REPLACE FUNCTION private.db_pre_request () returns void language plpgsql stable security definer
set search_path = public as $function$
declare groups jsonb;
begin -- get current groups from auth.users
select raw_app_meta_data->'groups'
from auth.users into groups
where id = auth.uid();
-- store it in the request object
perform set_config(
'request.groups'::text,
groups::text,
false
/* applies to transaction if true, session if false */
);
end;
$function$;
grant usage on schema private to authenticated,
postgres;