Created
March 6, 2021 14:01
-
-
Save pdbradley/84b491637c2ddcbeb33f706439df57fd to your computer and use it in GitHub Desktop.
find_or_create SQL function
This file contains hidden or 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 | |
OR REPLACE FUNCTION public.find_or_create_user(user_email text) RETURNS SETOF users LANGUAGE sql STABLE AS $ function $ | |
INSERT INTO | |
users (email) | |
VALUES | |
(user_email) ON CONFLICT (email) DO NOTHING; | |
SELECT | |
* | |
FROM | |
users | |
WHERE | |
users.email = user_email; | |
$ function $ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment