From b8423f4d05c75094b7b9d09c6f0bb353acc9be1c Mon Sep 17 00:00:00 2001 From: ckonstanski Date: Sat, 25 May 2024 18:03:25 -0600 Subject: initial commit --- .../auth.get_active_role_groups_for_user.sql | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 sql/functions/auth.get_active_role_groups_for_user.sql (limited to 'sql/functions/auth.get_active_role_groups_for_user.sql') diff --git a/sql/functions/auth.get_active_role_groups_for_user.sql b/sql/functions/auth.get_active_role_groups_for_user.sql new file mode 100644 index 0000000..41f7712 --- /dev/null +++ b/sql/functions/auth.get_active_role_groups_for_user.sql @@ -0,0 +1,25 @@ +drop function auth.get_active_role_groups_for_user ( + p_user_id bigint +); + +create or replace function auth.get_active_role_groups_for_user ( + p_user_id bigint +) +returns setof auth.role_groups_t +as $$ +begin + return query + select urg.id as user_role_group_id, + urg.user_id, + rg.id as role_group_id, + rg.name, + rg.description + from auth.users_role_groups urg + inner join auth.role_groups rg + on urg.role_group_id = rg.id + where urg.user_id = p_user_id + order by rg.name asc; + + return; +end; +$$ language plpgsql; -- cgit v1.3