Prisma

P

Prisma

Join the community to ask questions about Prisma and get answers from other members.

Join

Count records where number of related records is greater than X

Hey folks, I'm struggling to figure out the right way to express a particular query. I have a model game and a related model like. A game has 0 or more likes related to it. What I want to get: the total number of games that have at least 5 related likes. Ideally I would do this without fetching unnecessary extra data from the database. Appreciate any help, thanks....

Can't reach database server at `aws-0-ap-southeast-1.pooler.supabase.com:5432

Environment variables loaded from .env Prisma schema loaded from prisma/schema.prisma āœ” Generated Prisma Client (v6.2.1) to ./node_modules/@prisma/client in 41ms ...

Gi,Migration 2 shemafiles...schma1.prisma

Respected sir, shema1.prisma and shema2.prisma Fules how to generate migration files for both in seperate folders....what cli command i can use #migrations Prisma folder in that this two files exists.... Thanks...

Using Prisma with Azure SQL Hyperscale

Is anyone using Prisma with Azure SQL Hyperscale? I am running into an issue that when the sql azure scales up or down there is a massive slow down in the application and errors from disconnections of the connection pooling. I am curious how others may have solved this. In .NET's EF they had automatic retry logic but is there an equavaliant in Prisma?...

why update/delete need the 'select' statement to not be empty??

will throw an error: ``` const deletedUser = await prisma.user.delete({ where: { id: 1 },...

Misleading error message: ERR_INVALID_ARG_TYPE

So i was trying to use raw sql but i forgot to account for @map values in my prisma schema so i was trying to update a column with the model name instead of the map name which i should have used in raw sql. However i ran into very weird error. The query itself was pretty simple: `` await prisma.$executeRaw UPDATE "users" SET "pending_actions" = array_remove(pending_actions, ${action})...

Custom/composite IDs as relation references

I am exploring Prisma as an alternative to our current ORM/backend, Parse, due to it not being very well maintained. Overall, the migration is looking pretty clean, but I'm running into an issue around translating the way Parse did relations and the way Prisma does them (this is for a Mongo database). Parse does it by having a relation field (or "pointer") with a composite key string value of ClassName$RecordID (i.e., Author$a43fE3f3) instead of the way Prisma does it where you define the cl...

If I extend create, is there a way to extend createMany as well?

Hi, I'm looking to extend the create method for one of my Models, but is there a way to simultaneously extend createMany? I asked the AI and it said that I'd have to manually update both, but would extending createMany to call create under the hood be a reasonable approach or would it be bad for some reason?

Prisma Pulse development flow

Hey all, am working on implementing prisma pulse, very cool tech. However I'm concerned about the development flow versus a production flow. What is the recommeneded path for this? How should I implement a localhost postgres db to work with prisma pulse?...

Initial value for data in my table

Greeting I want add initial value zero for this table How can i do it ?...
No description

Multiple roles for a user

I have a scenario where a user can have multiple roles at the same time. For example a user can be editor and translator. What is the recommended approach for this situation?...

Issue with seeding in Next.js + Prisma + Docker + SQLite

Hi everyone, I have an application with Next.js, Prisma, Docker, and SQLite. Everything works fine in development, but when I run the Docker image and execute the npm run seed command, the data is successfully added, but it doesn't reflect in the application until I restart it. This also happens when using Prisma Studio. Has anyone experienced a similar issue? How can I resolve it? I ran the container with npm run dev and everything worked fine. Does anyone know what it is causing this behavior? And how can I make it work with npm run start? Thanks in advance #...

BLOB in prisma schema

Is there a way of storing BLOB in prisma schema? Please if you know tell me the aswer and don't tell me "don't store images in db", use S3 or something like that
Solution:
Hey šŸ‘‹ Yes, you can use Bytes type to store BLOB data: https://www.prisma.io/docs/orm/reference/prisma-schema-reference#bytes...

Using Prisma inside firebase functions

Hey guys, I have a backend that runs mostly on Firebase/Firestore functions. However, we started migrating some tables to a PostgreSQL DB and I'm trying to use Prisma on Firebase. Connecting locally and deploying are already figured out by using a VPC + pg-pool. The issue is that when deploying the Firebase functions my code can't find the client library that is being generated. My package.json `"scripts": { "build": "tsc",...

mongodb connection with prisma

I tried pushing my mongodb database from the command line, and i am getting The provided database string is invalid. An invalid argument was provided: Database must be defined in the connection string in database URL. Please refer to the documentation in https://www.prisma.io/docs/reference/database-reference/connection-urls for constructing a correct connection string. In some cases, certain characters must be escaped. Please check the string for any illegal characters.

Prisma Optimize Issue

My code is attached, I am fetching classes from my database which has assignments inside of it. Then, the assignments and classes are mapped in a seperate component that is inside the skeleton. Assignments are mapped inside the classes map. I'm not sure how to make this lightning fast but it sometimes takes 5 seconds to load even on production. https://cdn.discordapp.com/attachments/1331006139244085278/1331012480964628582/Screen_Recording_2025-01-20_at_1.27.48_PM.mov?ex=67901178&is=678ebff8&hm=fbe72a3de16c8c35da39f95caef198955b81682f4be84df338ab8b779612b999& this video gets t1 (before the prisma call) and t2 (after the prisma call) and prints t2-t1 to see how long the prisma call took. ...
No description

how do you manage very large models in nextjs?

So I made an app in nextjs and the user model is HUGE, around 70 lines of fields + relations, orders, products, chats, messages, reviews as buyer, as seller, followers, notifications and many fields. The app isn't slow but I don't want the app to carry this information in everyplace because not all fields are necessary all the time and also I want to hide some information. How do you manage large objects in your nextjs app with prisma?...

Prisma Playground Run button doesn't working

Idk why this happens, but I can't run any code in examples, run button just stuck on infinite loading šŸ˜µā€šŸ’«
No description

Nullable unique field on Prisma

Hi, @everyone, I have a Prisma model on MongoDB. ``` model StakeTx { txId String @id @map("_id") stakeId String? @unique @db.ObjectId...

'ts-node' is not recognized

I understand that this error comes from that ts-node is not installed globally . I want to report that in the seeding guide, there is written " Add typescript, ts-node and @types/node development dependencies: " npm install -D typescript ts-node @types/node and ...