Prisma

P

Prisma

The official Discord for the Prisma ORM and Prisma Data Platform! Learn more at https://prisma.io

Join

Help with findFirst and none relations

I'm working on seeding my database for a self storage and I'm trying to randomly select a customer with no leases and assign them a lease. This is my code and it's alway returning the same customer: ` const customer = await prisma.user.findFirst({ where: { customerLeases: { none: {}...

Can't see relation field in Types

Hi, How do I make stages visible in my code? (What I mean is in the image attached, stages doesn't appear on the types for ProjectPage.) ```ts model ProjectPage {...
No description

Help with multiple prisma clients in a turbo monorepo

With the original Prisma setup in my production turborepo with 2 nextjs projects I, ran into an issue where after postinstall prisma generate overwrote each other iniside the node_modules . Therefore I found my exact issue here https://github.com/vercel/turbo/discussions/3493. and applied the fix that was mentioned here https://github.com/vercel/turbo/discussions/3493#discussioncomment-7090955. Now my project seems to build fine locally and it also build fine successfully on vercel. But when i to a page that has a db fetch it fails with th e following error. ```...

At what point is a query used up from the 60k

Is one consumed to get it into the cache or is one consumed per retrieval in the code

Contacts: error combining many-to-one with one-to-one on the same models

I'm just getting started modeling with Prisma and quickly hit a case I can't find help for in the docs. I want a Person to be able to have any number of Contacts, but exactly one primary Contact. My incorrect model looks like this: ``` model Contact { id Int @id @default(autoincrement()) email String...

Getting error when using Prisma Optimize

I am getting the below error when running my server with Prisma Optimize: ```ts PS C:\Users\william\Desktop\GitHub\test> npm run dev ...

How do the accelerate and read replica extensions interact?

If I have accelerate configured and working then add the read replica extension with a direct URL to a read replica I am assuming all reads would bypass accelerate right? What if I put another accelerate URL in the read replica configuration? Do write go to the one accelerate project and read go through the other accelerate project? Thanks!...

property 'data' does not exist on args when using $extends

Basically I was trying the method provided in the solution of this stack overflow post https://stackoverflow.com/questions/77435838/hash-password-in-prisma-orm whoever when building the index.ts file I get the following: ```src/index.ts:12:62 - error TS2339: Property 'data' does not exist on type 'UserFindUniqueArgs<InternalArgs & DefaultArgs> | UserFindUniqueOrThrowArgs<InternalArgs & DefaultArgs> | ... 13 more ... | UserCountArgs<...>'. Property 'data' does not exist on type 'UserFindUniqueArgs<InternalArgs & DefaultArgs>'....

NPM network error only when trying to fetch Prisma

I am using node:20.15-alpine image with docker compose. I recently deployed a similar project without Prisma and it worked. I have confirmed its not a network error by pinging the registry. I will post the error and and compose files to follow.

updateMany fails with "You can't specify target table 'Org' for update in FROM clause" error

For the following schema ```prisma generator client { provider = "prisma-client-js" }...

How can i implement Prisma Client as shared package?

i want to make npm package out of the generated prisma client so that my other apps can use and install the package and access the database is that possible?

@relation field referencing a compound id

Is there a way to have an @relation that points to a compound id on another table? Consider this scenario: https://www.prisma.io/docs/orm/prisma-client/special-fields-and-types/working-with-composite-ids-and-constraints ...

Slowness issue when using Supavisor connection pooling with Prisma

Hey Prisma community, I've set up Supabase Supavisor connection pooling on my Supabase project but it turns out that the request is abnormally slow with Prisma when I use supavisor. I compared the time it took to make a request with console.time and the result was clear. The tests are done locally with a remote postgres database hosted on Supabase with Supavisor enabled. I have the latest version of Prisma installed Here is my connection string in my .env...

unexpected message from server

Hi all, we see this error pretty randomly
error in connector: error querying the database: unexpected message from server
I try to replicate with the same query, but the error persists. Is this the kind of error wherein it makes sense to implement some kind of retry logic?...

Accelerate SWR option not re-fetching/revalidating cache

If my understanding of the SWR strategy is correct, the cache is supposed to be revalidated after each request (even if the cache served old data). In my user profile component, I'm fetching the user's information from the database. When an update gets made (e.g. the user's name), refreshing the page still displays the old information. I would expect this to be the case for the first couple refreshes after the update has been made (since the cache is being revalidated/refreshed in the background), but even after a full minute the query result keeps returning the old user information. Why is the cache not being revalidated/refreshed in the background??...

Types are broken because of read replicas extension

I am exporting this singleton in my whole application ```ts const prisma = new PrismaClient({ log: ['info', 'error', 'warn'], }).$extends(...

How do I go about seeding with the D1 adapter?

Hey all, I have recently started using the D1 adapter and I am a bit confused around how seeding should be handled. Initially I thought it would be the same as other DB's so I was following the guide here: https://www.prisma.io/docs/orm/prisma-migrate/workflows/seeding#seeding-your-database-with-typescript-or-javascript. The issue is when using the D1 adapter it requires a binding to the D1 database instance which comes from the Cloudflare workers context. Since the seed script would run outside...

Sort by nulls

Is there a way to sort and not show nulls or empty strings? I added last: null, but it doesn't work : ```ts this.prisma.toSource.findMany({ where,...

Prisma Enum Mapping

I have this enum in my prisma.schema is there a way for me to map it the same way as I map in my schema? ```ts enum CombatCategory { TANK_MELEE @map("M1")...
No description
Next