-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: RPC get_user_by_mobile RPC for Admin
- Loading branch information
1 parent
7ce2889
commit bc4fd3f
Showing
7 changed files
with
467 additions
and
14 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import { PrismaClient } from '@prisma/client' | ||
import { create_profile_on_signup } from './seeds/create_profile_on_signup' | ||
import { PrismaClient } from '@prisma/client'; | ||
import { create_profile_on_signup } from './seeds/create_profile_on_signup'; | ||
import { create_get_user_by_mobile } from './seeds/get_user_by_mobile'; | ||
|
||
const prisma = new PrismaClient() | ||
const prisma = new PrismaClient(); | ||
|
||
async function main() { | ||
await create_profile_on_signup(prisma) | ||
await create_profile_on_signup(prisma); | ||
await create_get_user_by_mobile(prisma); | ||
} | ||
|
||
|
||
main() | ||
.then(async () => { | ||
await prisma.$disconnect() | ||
await prisma.$disconnect(); | ||
}) | ||
.catch(async (e) => { | ||
console.error(e) | ||
await prisma.$disconnect() | ||
process.exit(1) | ||
}) | ||
console.error(e); | ||
await prisma.$disconnect(); | ||
process.exit(1); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
|
||
export async function create_get_user_by_mobile(prisma: PrismaClient) { | ||
await prisma.$executeRaw` | ||
CREATE OR REPLACE FUNCTION public.get_user_by_mobile(mobile text) | ||
RETURNS SETOF auth.users AS | ||
$$ | ||
BEGIN | ||
RETURN QUERY | ||
SELECT | ||
-- id, email, email_confirmed_at, invited_at, | ||
-- phone, phone_confirmed_at | ||
-- raw_app_meta_data, raw_user_meta_data, is_super_admin, | ||
-- created_at, updated_at, deleted_at | ||
* | ||
FROM auth.users WHERE phone = mobile; | ||
END; | ||
$$ | ||
LANGUAGE plpgsql | ||
SECURITY INVOKER; | ||
`; | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FAST2SMS_API_KEY= |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Updating Secrets | ||
|
||
``` | ||
supabase secrets set --env-file ./supabase/.env | ||
``` |
Oops, something went wrong.