Created
January 25, 2017 14:56
-
-
Save tlaitinen/0d842ea4255de1752436f7ef49a40036 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION has_role (userId BIGINT, userGroupId BIGINT, role TEXT) | |
RETURNS BOOLEAN | |
AS | |
$$ | |
SELECT EXISTS ( | |
SELECT 1 | |
FROM role | |
WHERE user_id = $1 | |
AND user_group_id = $2 | |
AND role = $3 | |
AND active = true | |
) | |
$$ | |
LANGUAGE SQL | |
STABLE | |
STRICT; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment