From ef9b94cbf500dbac1ae71c8fb1a549f030e4b555 Mon Sep 17 00:00:00 2001 From: warmachine028 <75939390+warmachine028@users.noreply.github.com> Date: Sun, 25 Aug 2024 14:37:26 +0530 Subject: [PATCH] feat: added Prisma db --- client/prisma/schema.prisma | 21 +++++++++++++++++++++ client/public/file-text.svg | 6 ++++-- client/public/globe.svg | 20 +++++++++++--------- client/public/next.svg | 7 ++++++- client/public/vercel.svg | 18 +++++++++--------- client/public/window.svg | 6 ++++-- client/src/lib/prisma.ts | 15 +++++++++++++++ 7 files changed, 70 insertions(+), 23 deletions(-) create mode 100644 client/prisma/schema.prisma create mode 100644 client/src/lib/prisma.ts diff --git a/client/prisma/schema.prisma b/client/prisma/schema.prisma new file mode 100644 index 0000000..fa0ec47 --- /dev/null +++ b/client/prisma/schema.prisma @@ -0,0 +1,21 @@ +// This is your Prisma schema file, +// learn more about it in the docs: https://pris.ly/d/prisma-schema + +// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? +// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init + +generator client { + provider = "prisma-client-js" + previewFeatures = ["fullTextSearch"] +} + +// datasource db { +// provider = "postgresql" +// url = env("DATABASE_URL") +// } + +datasource db { + provider = "postgresql" + url = env("POSTGRES_PRISMA_URL") // uses connection pooling + directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection +} diff --git a/client/public/file-text.svg b/client/public/file-text.svg index 9cfb3c9..172a26c 100644 --- a/client/public/file-text.svg +++ b/client/public/file-text.svg @@ -1,3 +1,5 @@ - - + + \ No newline at end of file diff --git a/client/public/globe.svg b/client/public/globe.svg index 4230a3d..ecf90bb 100644 --- a/client/public/globe.svg +++ b/client/public/globe.svg @@ -1,10 +1,12 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/client/public/next.svg b/client/public/next.svg index 5174b28..4f5db82 100644 --- a/client/public/next.svg +++ b/client/public/next.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + \ No newline at end of file diff --git a/client/public/vercel.svg b/client/public/vercel.svg index 0164ddc..d0794ba 100644 --- a/client/public/vercel.svg +++ b/client/public/vercel.svg @@ -1,10 +1,10 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/client/public/window.svg b/client/public/window.svg index bbc7800..7305ca0 100644 --- a/client/public/window.svg +++ b/client/public/window.svg @@ -1,3 +1,5 @@ - - + + \ No newline at end of file diff --git a/client/src/lib/prisma.ts b/client/src/lib/prisma.ts new file mode 100644 index 0000000..8d1d982 --- /dev/null +++ b/client/src/lib/prisma.ts @@ -0,0 +1,15 @@ +import { PrismaClient } from '@prisma/client' + +const prismaClientSingleton = () => new PrismaClient() + +declare global { + var prismaGlobal: undefined | ReturnType +} + +const prisma = globalThis.prismaGlobal ?? prismaClientSingleton() + +export default prisma + +if (process.env.NODE_ENV !== 'production') { + globalThis.prismaGlobal = prisma +}