Ask Your Question
2

How to integrate Prisma Client with Supabase Edge Functions?

asked 2023-05-13 15:21:01 +0000

devzero gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-05-13 15:22:01 +0000

woof gravatar image

To integrate Prisma Client with Supabase Edge Functions, follow these steps:

  1. Create a new Edge Function in your Supabase project.

  2. Install Prisma Client in your Edge Function's dependencies by running the following command in your Edge Function's directory:

npm install @prisma/client
  1. In your Edge Function code, import Prisma Client and create a new instance:
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
  1. Use Prisma Client to perform database operations within your Edge Function:
const result = await prisma.user.findMany();
  1. Remember to close the Prisma Client connection before your Edge Function finishes executing:
await prisma.$disconnect();

That's it! You can now use Prisma Client in your Supabase Edge Functions to interact with your database.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-13 15:21:01 +0000

Seen: 16 times

Last updated: May 13 '23