Prisma

P

Prisma

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

Join

Multiple Schema File issues

hi, so im using as followed on the blog about multiple schema files, and it seems that when i try to use npx prisma format or npx prisma generate, it fails to load those other schema files, i dont have any model in main file tho, so not sure if that's the issue, but it shouldnt be, here's also my file tree: ```shell prisma ├── schema...
Solution:
seems like all files have to be in the schema directory, that's kinda annoying

Prism generate fails on VPS but not locally

executing this script inside CMD in Dockerfile, it fails thjough, any idea where a problem could be?...
No description

How to utilize Prisma defined in back-end to the front-end

Hello. I'm developing a project without NextJS, just using Vite TypeScript React. I've decided to use Prisma in my NodeJS backend. I'm currently writing out components for React and it would be really handy to be able to use the types defined in my Prisma schema from the back-end in my front-end. Is there any way I can do this without creating a reference to my backend in my frontend? (Trying to maintain decoupled architecture)...

How to include prisma/sql in serverless lambda?

I'm using serverless-webpack-prisma to include prisma client in lambda but I don't think it currently includes prisma/sql in the deployment as I get the following error: "Runtime.ImportModuleError: Error: Cannot find module '.prisma/client/sql'".

how do I do this upsert query in prisma?

```pgsql INSERT INTO public."CartItem" ("itemId", "userId", "quantity", "ordered") VALUES (${product.id}, ${user.id}, 1, false) ON CONFLICT ("itemId", "userId") DO UPDATE SET ...

Complicated groupBy query

Hey there, I am attempting to do something with Prisma that may be undoable. I am still very new to web dev and Prisma, so be aware I don't doubt I'm missing something obvious here. I would like to use post.findMany() to find posts for a specific user, but in this query I would like to include the number of reactions associated with a post for a kind of reactionType. In my project, I am using emoji reactions on posts, and I need to return the number of reactions per emoji type (reactionType). However, I am at a loss for how to do this without many queries per request. Using groupBy() works if I grab the posts first and then use the post.id of each post... ...
Solution:
Hey Jon, your query worked well. I modified it return the structure I needed: ```sql -- @param {String} $1:Post ID -- @param {String} $2:User ID...

"prisma generate --sql" keeps on hanging

I'm trying the new preview version of Typed SQL, and it sounds amazing. However, when I try to run the prisma generate --sql command, it stops and hangs after the "Prisma schema loaded from prisma/schema.prisma" step. I've installed version 5.19.0 of both Prisma and the Prisma Client...

prisma 5.19.0 preview feature "typedSql" not valid feature

According to the Prisma documentation, version 5.19.0 should support the preview feature "typedSql". However, after installing the latest version of Prisma and Prisma Client (5.19.0), the preview feature "typedSql" is not recognized as a valid feature.
Solution:
Thanks jjmm, Restarting the vs code extension solved the issue.

How do I rollback a prisma transaction when I have 2 different prisma clients

```js const prismaPostgres = new PrismaPostgres(); const prismaMsSql = new PrismaMsSql(); await prismaMsSql.$transaction(async (prismaMsSql) => {...

How to handle default items alongside user-created ones?

If I have an application with default data that all users see, and also those users can create their own data that's the same type of data as the default data, which they can update and delete. How would I handle this in my database schema? I was thinking of using an admin role or maybe even have Boolean for system defined data but I'm not too sure. What do you guys think?...

Typescript clutter: Prisma + Postgresql + JSON fields is a mess

Guys all my code is cluttered with typecasting Prisma.JsonValue Prisma.JsonObject Prisma.JsonNullValueInput...

Prisma + Turborepo build fails in Vercel

I have a turborepo with prisma as a package , when running locally everything works, even builds locally too, but when I am deploying the project it throws an error stating DATABASE_URL is not present: Environment variable not found: DATABASE_URL....

How can i string filter but for number?

Hey im still new to prisma and basically i want this getId Method to work: `async test(id) this.prisma.idTable.findMany({ where: {...

Unique constraint fails when creating user(s)in parallel during tests for api endpoints

When I run tests in my app in parallel that have helpers that create users in the DB, i get this error: ``` FAIL ../test/cartridge.test.ts > /api/cartridge > post /api/cartridge - create a cartridge PrismaClientKnownRequestError:...

[SOLVED] Prisma won't build consistently with the same Dockerfile specs

Hi, when bundling an app with Prisma, it works on a node:20 and node:20-alpine locally. When building with the same machines on Github Action ubuntu-latest runner they fail with the following error:
PrismaClientValidationError: Invalid client engine type, please use `library` or `binary`
PrismaClientValidationError: Invalid client engine type, please use `library` or `binary`
...
Solution:
Solved: Missing NEXUS_STANDALONE environment variable in "base as build" Docker execution context. Rationale: in my local machine, the environment variable was available at a higher reference point....

Ordering by a nullable relation

Hello everyone, so I have the following schema: ```...

Error: P3005 The database schema is not empty.

I want to initialize prisma in an existing supabase project. All schemas in datasource db.schemas are empty, and public._prisma_migrations does not exist. I have the initial migration in migrations/0_init/migration.sql, generated via https://www.prisma.io/docs/orm/prisma-migrate/workflows/baselining I'm getting Error: P3005 The database schema is not empty. with either prisma migrate dev and prisma migrate deploy. In addition prisma migrate reset also has the same error. ...

Eloquent's relations equivalent in Prisma?

While it doesn't make a big difference in DX, Eloquen's relations do save some time and make it fun to type those short DSL queries. I haven't skimmed through the whole doc of Prisma, but is there an equivalent to what I described?...

db push stuck

hello! when running prisma db push it logs that the schema is loaded then logs the datasource then does nothing! what do I do?
Solution:
It happened to me some time ago, then I realized that the database port in the connection URL was incorrect. Try to check it.