Prisma

P

Prisma

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

Join

Prisma seeding

I'm having an issue with my prisma seeding, idk what is happening, there is no 'g' whatsoever in any place, i've been struggling with prisma my whole week and it just keeps appearing errors after errors that makes no sense, ```// This is your Prisma schema file, // learn more about it in the docs: https://pris.ly/d/prisma-schema...
No description

Searching by null returns no results

Given an example model like this: ```ts model Item { name: String...

ExpressJs Transactions

Is there a best practices or best way to wrap all requests to an ExpressJS API server in a transaction. I would like to start a transaction for any request going to /api and then either commit on successfully return or rollback if an error occurs. If possible I would like this to be as transparent as possible. Is such a thing possible? Thanks!

Generating Prisma Client

I am trying to better understand how to correctly import the client from https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/generating-prisma-client I have used the new configuration: ```js generator client { provider = "prisma-client-js"...

Prisma 6.6.0: Unable to use Prisma.JsonNull and Prisma.DbNull due to "We could not serialize [object

I have hit a problem that is affecting both dev and prod... on a Friday night. Any help on the GH issue would be helpful: https://github.com/prisma/prisma/issues/26987...

Dmmf in frontend

Hi, I need to determine whether a database field is an array. To achieve this, I’ve created a function that uses Prisma's DMMF. Additionally, I want to associate multilingual labels with each field in the database. For this, I’ve defined a typed object that maps each field to its translated labels....

Prisma Postgres performance

Hey Prisma team, could anyone shed some light on the disparities shown at https://bejamas.com/compare/planetscale-vs-prisma-postgres ? Particularly, the "Cold Query". I've been considering switching from PlanetScale to Prisma Postgres for a while now, and the difference in "Hot Query" seems acceptable (for North America at least), but I wasn't sure what the cold queries were even referring to here, since in most places I've gotten the impression that Prisma Postgres shouldn't have cold starts (not sure if that's different from cold queries)...

How to get proper type for relation from two different include queries.

I'm building a Next.js app for a personal project building a GUI for a sqlite db as a learning exercise. I opted for Prisma here and have been working my way through typing issues. A quick run down of my scheme: player with id and name, deck with id and name, game with id and datetime, anddeck_game with a bulk of the data (in hindsight, not a great name). deck_game has an id, a game_id, player_id, deck_id, and position. How this works is for each game that's played, I track what player was in it, what deck they had, and what position they finished in. So in a 4 player game I'd have 4 deck_game rows matching the game_id, with the player_id and deck_id matching their respective tables, and the position that player/deck finished in. For my app, I've made several Prisma calls with some complicated includes....

Dynamic select column doesn't return the correct type

Hello, I have an issue with a particular query I'm trying to run. I have a relation model called 'Posts' and in this particular query I only want to include posts if a specific condition is met before hand (i.e. condition ? { /* select */ } : false). When doing this the return type changes, seek below result. ```ts const user = await this.prismaService.users.findFirst({ select: {...

Schema Troubleshooting

Hi everyone reposting this, i have a pretty simple Schema with three models. However, whenever i try to push the schema to my MYSQL DB, i keep running into foreign key restraints. I don't see anything wrong with my relations thats causing this to occur. One thing to note is that i did accidentally migrate the schema to my db, but i went and dropped the table and the migration folder. Did I make a silly syntax mistake that i'm missing, or will i need to baseline my db due to migrations being out...
No description

Relations on non unique fields

Hi guys, i'm building a new db and i need it to be multilingual. in order to achieve that i've created a contents table wich will handle every text/image for each language ```prisma model Contents { id Int language Languages...

Upgrade from 6.0.1 -> 6.5.0 broke migrate dev

I recently upgraded from 6.0.1 to 6.5.0, and didn't change any migrations or schema files. But when I run migrate reset and then run migrate dev I am now receiving an exit code of 130 whereas previously I could generate migrations without issue. This happens regardless of if I modify a schema file or not. The output of the command looks like this: ``` Drift detected: Your database schema is not in sync with your migration history....

Prisma PostgresProvisioning stuck?

Hello. Im quite new to prisma, but when I set up a new environment, it just states "Provisioning" and under setup "Almost there! Your database will be ready shortly."Anyone that knows what can cause this? I have 6 environments available in my plan, so that should not be the issue. Thanks!...

Prisma Client could not locate the Query Engine for runtime "rhel-openssl-3.0.x"

Hello. I have been using Prisma for years and love it. However, I am having an issue with a new project when deploying to vercel. It's seems this is a fairly common issue, as there is an entire github post about it here:https://github.com/prisma/prisma/discussions/19498. In the last two weeks, it seems 3-4 other people have had the same issue, yet none of these have been responded to. I was wondering if there is a known solution/if this is currently being worked on?

Module build failed: UnhandledSchemeError: Reading from "node:async_hooks" is not handled by plugins

I'm on a Next.js 14 app and just switched from 6.5.0 to 6.6.0, but now I'm seeing the error Module build failed: UnhandledSchemeError: Reading from "node:async_hooks" is not handled by plugins (Unhandled scheme). Webpack supports "data:" and "file:" URIs by default. You may need an additional plugin to handle "node:" URIs....

Migrating from MongoDB to PostgreSQL: How to handle embedded types/objects?

I'm an intermediate developer working with Next.js, Node.js, and React. I'm currently using Prisma with MongoDB for my project, but I'm considering migrating to PostgreSQL. One of my biggest challenges is figuring out how to handle embedded types/objects that I use extensively in my MongoDB schema. For example, I have structures like: ```typescript...

How to make a library/package that expects a Prisma client with a certain schema?

Hi, I'm currently trying to make it so I have my Prisma Schema as a private GitHub package that I can consume in various environments and projects, using the new prisma-client generator, which expects an output path. I have my package called @blabla/prisma-client, which exports all Prisma types from the generated client (e.g ./generated/client), after having been built with tsc, to output .d.ts files, which are all I really care about, to use in different projects. I import that package into my modules which accept a Prisma Client on initialization, to use its types, and then I export my functions and classes for consumption in a different project....
No description

[email protected] type error when prismaClient generated at specific folder with "cjs" module type

@Prisma @Prisma AI Help I've been trying to use prisma v6.6.0 with nestjs app and generated to cjs module format but I kept getting type error at runtime...

Running "prisma db push" leads to migration failure

It works if I run yarn prisma db push for the first time on a new database. Run that again, I get error: ``` Error: ERROR: type "TriggerType" already exists 0: sql_schema_connector::apply_migration::migration_step...

Synchronous functions

I need to query a DB from a synchronous function. Unfortunately making it async isn't possible because it implements an interface that I can't touch. I also can't just ignore the promise because the said sync function actually processes the data returned from the query. Is there any solution?
Next