Prisma

P

Prisma

The official Discord server of Prisma! Find us online at prisma.io

Join

Prisma Connection Pool

Hey! We are using Prisma in serverless on GCP, the serverless currently configured with 4 CPUs, hence making Prisma setting the connection pool to 9 by default. This low amount of connection pool making our application very slow, espacially because we currently have only one instance of our backend. ...

What are the best practices for using Postgres array functions within a Prisma query?

I want to include cardinality("comments") AS "commentsCount" in my SELECT clause, but I'd prefer not to have to make the entire query raw. Is there some way to get around this? I'm imagining something like the following: ``` prismaService.posts.findMany({ select: {...

Issue with prisma optimize

Hello, I have an issue with prisma optimize Error: prisma:client:operation span is expected to be entered in the client extension when tracing is enabled at Array.$allOperations (C:\Users\simon\Desktop\diamond-presence\node_modules@prisma\extension-optimize\dist\index.js:4:1103)...
Solution:
Hey @simnJS Which version of optimize are you using? Is it 0.10.0?...

using prisma $extends to add fields to a model, whats the best practice for TS?

Below is how i add a custom "client" field to my tokens model - but now my Token model doesn't really match since there is no client field in that. What is the best practice for taking care of that? ```ts const prisma = globalThis.prismaGlobal ?? prismaClientSingleton().$extends({ name: 'tokenParser',...

Does it make sense to create an explicit one-to-many relation?

I'm reading the docs but can't find an example of an explicit one-to-many relation. Maybe it doesn't make sense to create an explicit one-to-many relation?

Alternative to solving optimistic concurrency issue without version field

In the following page there is a suggestion how to solve concurrency issue by adding a version field and ask about it in the where clause when updating a model: ``` const userEmail = 'alice@prisma.io' const movieName = 'Hidden Figures'...

Can't use dotenv and ws for edge runtime in authjs middlware. Help any solutions?

I am trying to set up Prisma with Neon in the Next-Auth v5 beta. I am running into an error where if i include dotenv or ws the middleware doesn't work because those packages use node run time. I took out the dotenv and ws it creates a new user but I don't know if this is correct. What is there purpose? Can i access the .env without "dotenv" and what is the purpose of ws? Below is my prisma.ts file. What is the correct way to do this? I tried removing ws and replacing with websocket does that work? //prisma.ts import { Pool, neonConfig } from "@neondatabase/serverless"; import { PrismaNeon } from "@prisma/adapter-neon";...

Prisma ORM DocumentDB AWS

Hello guys, I refactored an entire application with node js, prisma orm, mongodb, but in production it is used with documentdb of aws with mongodb and I had not attacked this when I did all the refactoring, now I went up to production and I'm having the compatibility error with the $$remove that the prism uses. Do you have any alternative to get around this problem?...

Error: PrismaClientUnknownRequestError:Invalid `prisma.user.groupBy()` invocation:

``ts Error: PrismaClientUnknownRequestError: Invalid prisma.user.groupBy()` invocation: ...
Solution:
with Prisma Accelerate connection string
No description

Connections are over connection limit

I deployed my NextJS + Prisma on a dedicated server then I noticed that the connections on my Postgres database is higher than the connection limit. I set my connection limit to 30 (?connection_limit=30) but the connections go to around 70 - 80. You can see it from the graph. I already made sure if the data from the graph is correct by using this query. ```sql SELECT client_addr,...
Solution:
In the end, it's not problem with Pisma. It's problem with our PM2 config. We set instances to "max" which is too much. I reduced the instances number and it works now. Thank you for support. @Nurul (Prisma)
No description

Prisma type inference is returning weird types

I'm encountering an issue with TypeScript not properly inferring the types when using PrismaClient in my Node.js typescript application. Setup: Prisma Schema:...

Issues with Prisma 5.3.1: OpenSSL Version Mismatch during Build and Runtime in Docker

I am encountering issues with my setup involving Prisma 5.3.1 and Docker. During the build process, I receive the following error: in this GitHub issue, https://github.com/prisma/prisma/issues/16232 which suggests that there is no need to install OpenSSL manually. However, this did not resolve the issue for me.Is there a specific configuration I am missing in my Dockerfile or schema.prisma file that can ensure compatibility? Is there a recommended way to ensure that the Prisma Client is correctly generated for the required OpenSSL version within a Docker environment? Project Details: ...

prisma client generates model with no create

``` model Session { id Int @id @default(autoincrement()) userId Int user User @relation(fields: [userId], references: [id])...

Type 'Promise<string>' is not assignable to type 'string'

I'm seeding data to my project but when creating the user generates this error, can someone help me?
No description

Count with distinct

The scenario is: I have many inventories that are associated with a single tree (Many to One). ``` model Inventory { id Int @id @default(autoincrement())...

I/O error: Device or resource busy

I'm getting this error sometimes, what does it mean? `` { "success": false, "message": "\nInvalid prisma.pickaxeUser.findUnique() invocation:\n\n\nRaw query failed. Code: unknown. Message: Kind: I/O error: Device or resource busy (os error 16), labels: {"RetryableWriteError"}`"...

Convert LONGTEXT to JSON with prisma db pull

I have 10.6.18-MariaDB database and whenever I'm trying to set the column type to Json it changes to LONGTEXT but I already know I can't change that so my question is if can I somehow force the prisma db pull command to see LONGTEXT as JSON instead so I don't need to manually change that every pull?

npx prisma generate wont update the Product model.

Hey, I'm working on a simple e-commerce with next.js/prisma. And when I update the Product model the client doesn't update the types for Product. Here is the prisma.schema model Product: ```...

Otel integration

I am trying to set up otel with the @prisma/instrumentation package. Unfortunately, i am running in the following issue:

Do i need accelerate for Mongodb?

Hey guys, just a quick q. Im using prisma accelerate for connection pooling and I do not make use of caching as the project im using it for does not need caching at all. Would it make sense to use Prisma orm without accelerate and pooling via the mongodb connection string?