Prisma

P

Prisma

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

Join

Add Model Extension methods

Hey so I'm using Prisma client extensions to add some methods to my instantiated database objects. However I find cases where either some external force strips the methods off the object or I need to. I would like to be able to reattach them. Is there a way to do this? Like run the model through a Prisma.applyExtensions(modelName, data)...

union type findMany

I want to be able to query in prisma using a variable which is a union type over mulitple model tables. so instead of ```ts const model : 'user' | 'post' | ...; const id : number = 1;...

How to cascade delete properly in a self-relation with mongodb ?

It is written in the doc that we need to set NoAction on self-relation database but how are we supposed to do it ? I tried getting all ids and using a deleteMany to delete parent and children together but I got a PrismaClientKnownRequestError. ```prisma...

[Typescript] Prisma result extension typing

How can I get proper typing in a prisma result extension for $allModels? For a simple example, I want to return the same type available in a Model.create for any model

will prisma support zod validations natively

I know there are plugins, but they all seem to be out of date and have issues with them not being always correct. I really wish this was natively integrated given how important this is to have. it just needs more cod gen in the generate function...

@unique on optional field

``` model Player { id String @id @default(auto()) @map("_id") @db.ObjectId steam_id String @unique ......

Why have "id" and "modelName" been left out of Pulse subscription event types?

export interface PulseCreateEvent<T> { created: T; action: "create"; } export interface PulseDeleteEvent<T> {...

Unknown argument xx. Available options are marked with ?.

Hi everyone, I have an error that I can't solve and I wanted to know if anyone sees an error in my model? I've been stuck on it for a while and I don't really understand why, even though everything seems right. IIt can either be linked to a Track or a Car (not both at the same time), which is why I've added the null option. ```js...

Trying to get into Prisma; lots of hope and heartbreak

Hello! I've been trying to get into Prisma more and more because of the incredible promise and functionality it offers 99.9% of the time. However, I've unfortunately been experiencing some heartbreaking issues that just don't seem to make sense. I am running Node 18.13.0 compiled to js on my server and 20.10.0 pure ts on my pc. Both experience same issues....
No description

How to Implement an Optional One-to-One Relationship in Prisma with MongoDB?

Context I'm using Prisma 5.10.2 with MongoDB and attempting to set up an optional one-to-one relationship between two models based on the official Prisma documentation. However, I've encountered a problem with MongoDB's support for nullable unique fields. Models...

SOLVED: Create w/ sub create: Subquery returned more than 1 value

Per the documentation, I'm fairly certain I'm using this correctly. However, I'm getting the following error. We are on MSSQL and Prisma 5.11.0 `` "PrismaClientUnknownRequestError: Invalid prisma.testimonials.create()` invocation:...
No description

SQLite Timeout issues

I am having issues with Prisma + Sqlite. Essentially I believe Prisma isn't setting sqlite busy_timeout or something. There is a long history with this issue, see here ...

Returning the next day closest to NOW

So I have a list of dates, and im trying to return the next date that is closest to new Date.now(); Here is the code: ```ts const course = await db.course.findFirst({...

prisma nested fields

is it okay in terms of performance to have many nested fields in prisma? ``` const user = await prismadb.user.findUnique({ where: { id }, include: {...

Get the next date with prisma

```ts const course = await db.course.findFirst({ where: { slug: params.slug, },...

P3005 Error running Prisma migrate

I am working on a NextJS project that uses prisma. I was able to define my initial schemas and deploy my initial migrations successfully. I made a small change in the diff screenshot attached to this message and I am able to run npx run db push with no issues. When I try to run npx prisma migrate dev to generate a migration, I get the following error: ``` Error: P3005 ...
No description

i want a field to be an array in my mysql schema

I've created my model but in the image field I want it to be an array, so I can insert many images. Is there a solution? generator client { provider = "prisma-client-js" }...

Wierd type error with prisma codegen

29.01 qrtag:build: ./prisma/client/runtime/edge-esm.js:1:1
29.01 qrtag:build: Type error: Declaration emit for this file requires using private name 'i'. An explicit type annotation may unblock declaration emit.
29.01 qrtag:build: ./prisma/client/runtime/edge-esm.js:1:1
29.01 qrtag:build: Type error: Declaration emit for this file requires using private name 'i'. An explicit type annotation may unblock declaration emit.
...

why that not work?

Code: ```ts await prisma.pedOutfitFolder.upsert({ where: { userId: this.db.id, name: 'root' }, update: {},...
No description