Prisma

P

Prisma

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

Join

Using a JSON field as an id

Hello! I want to cache API results in the database and I was wondering if it'd be possible to use the id in the JSON field as an id, perhaps through @@id or some client extension?
Solution:
Hello @PIat πŸ‘‹ You could store the API result in a JSON field and also store the ID you want to use in a separate field marked as @id. However it won't be possible to skip having an id field altogether. You can use a client extension to manipulate the data before saving it to the database. So essentially, getting the id from JSON and using the same value in the actual id column...

"Something went wrong, please try again" ERROR

I cant use prisma pulse with superbase Database connection string i keep getting this error and dont know why "Something went wrong, please try again"...
No description

Query Performance

Hello, I wonder if there's any way to disable the extra SELECT queries made during updates. For example: This is the query I'm using to update a player. ```ts...

P3006 error I cannot run npx prisma migrate

this is the error `` Error: P3006 Migration 20241223102808_init` failed to apply cleanly to the shadow database....

TypedSql Array Parameter for Postgres

I am attempting to use array parameters as inputs to my queries, but when I generate the client I get the following error: Error: SQL documentation parsing: invalid type: 'Int[]' (accepted types are: 'Int', 'BigInt', 'Float', 'Boolean', 'String', 'DateTime', 'Json', 'Bytes', 'Decimal') at '{Int[]} $1:groupIds Array of group IDs to process'. ...

Executing data migration/data field seed script for a migration automatically

I did a quick search on the topic but didn't find any concrete solution I can use and it is quite the everyday case. Basically, I need to introduce a new required field in my db (postgres). The recommended solution is the expand-contract pattern where I first introduce the field as optional, then seed the data and then make it required in 2 separate migrations. For the data seeding aspect, I see a couple of options: default value in schema (which can reduce the migrations to 1), modify the migra...

PrismaClient is not configured to run in Edge Runtime

Stack: SvelteKit, Vercel, Prisma (Neon adapter) & Better Auth I've tried so many solutions I can't even recall half of them. I've spent about three hours trying to get everything up and running and I just can't get rid of this error (attached) Here's my related files, if anyone can help solve this I'd be forever grateful....
No description

Getting error this.getGlobalTracingHelper(...).dispatchEngineSpans is not a function

Hello! I just installed the prisma extension optimize, I'm using: - Node: 20.x - TypeScript: ^5.5.3 - Express: ^4.19.2...
No description

Logging client errors

Why the following code does not work? The create statement throws a Prisma.PrismaClientKnownRequestError with code P2002 (unique constraint violation). I don't need specific error handling (https://www.prisma.io/docs/orm/prisma-client/debugging-and-troubleshooting/handling-exceptions-and-errors), just a raw console.log of the error....
No description

Prisma Studio βž– Getting no records in T3 Stack

(dot)env with:
DATABASE_URL="postgresql://postgres:mysecretpassword@localhost:5432/databaseName?schema=public"
DATABASE_URL="postgresql://postgres:mysecretpassword@localhost:5432/databaseName?schema=public"
When typing the following: ```pnpm prisma studio...

Prisma examples - I ran through the ORM Fullstack examples and have some feedback:

overall: * no need to run npm install as that is done already βœ“ Should we automatically install packages for you? Yes * the default directory name starts with orm_...

Connecting to docker postgres database

When running the command npx prisma db pull ``` βœ” ~/Project_Development/carspectra [main L|● 1✚ 2] 05:25 $ npx prisma db pull Prisma schema loaded from prisma/schema.prisma...

Prisma Mongodb & Express Res API Docker

Hi I am tryin to create a docker compose that ecompasses A Rest API in Prisma and Express.js and a MongoDB Database. I am using this docker-compose file: name: 'proofifi-project' services: mongo:...

Programatic where clause based off query parameters.

I'm using fastify although I doubt that matters. Attached is pseudoish code. I am looking for a way to programmatically add to the where clause based off query parameters. If there are no query parameters, just do a select * from {table} I have searched the documentation pretty well, and searched blog entries etc, couldn't find an answer:...

Soft Delete with Nestjs

Hi everyone How I can implement soft deletes using Prisma and Nestjs? I found on the docs but is using middlewares, and for what I know, they are deprecated. Thanks for your time...

How to deploy to a self-hosted server?

At the moment I'm hosting my website on github pages, but I've kinda outgrown github pages now that my site needs a database. I have a spare machine lying around, so I'm trying to host my website off of it instead. Ideally I want to add some kind of a CI to automatically keep my site up-to-date whenever I push to github (and I think self hosted actions runners are the way to do this?) but I don't know how this would tie into prisma at all? I'm also super unsure if my project is set up right because I've gitignore'd the everything in the prisma folder except the schema I've got near-zero experience doing anything like this so please be patient with me!!...

Is there a way to generate model in prisma using cli?

I'm developing a white-label solution based on CLI inputs, and I'm wondering if there's an extension or tool that can assist with filling out a form using types and relations, which would then be automatically generated in the schema.prisma file.
Solution:
Hi Rev πŸ‘‹ I am not aware of any CLI tool to automatically generate schema file. There are other tools like https://prismaliser.app/ and https://prisma-editor.vercel.app/ which you may want to have a look at...

PrismaClientKnownRequestError: Invalid prisma.b2bTransaction.findUnique()

prisma table B2bTransaction exists in database cross-checked with the studio, but when try to use in hono on production, it gives this error:
PrismaClientKnownRequestError: Invalid prisma.b2bTransaction.findUnique() invocation: The table public.B2bTransaction does not exist in the current database.
PrismaClientKnownRequestError: Invalid prisma.b2bTransaction.findUnique() invocation: The table public.B2bTransaction does not exist in the current database.
...