Prisma

P

Prisma

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

Join

Prisma Migrate Diff coming back when it shouldn't

Our team is using Prisma as our ORM, and have a Github Action that runs
npx prisma migrate diff --exit-code --from-schema-datasource ./prisma/schema.prisma --to-migrations ./prisma/migrations --shadow-database-url
npx prisma migrate diff --exit-code --from-schema-datasource ./prisma/schema.prisma --to-migrations ./prisma/migrations --shadow-database-url
...
No description

Super slow queries when filter JSON

Hello, I asked the same question to @kapa.ai but couldn't figure out what to do basically my queries are super slow when running filters on raw JSON values with postgresql should I switch to mongodb?...

Error

```js // This is your Prisma schema file, // learn more about it in the docs: https://pris.ly/d/prisma-schema // Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?...

prisma azure swa is not working

I am trying to deploy prisma to azure swa (SvelteKit). Facing issues where prisma client not able to find libquery-engine-Debian-openssl-1.1.x.so.node not found. Please help

Counting hashtags in all posts

I want to build a Twitter-link "trending" feature for which I need to find and count the hashtags inside user posts. What Prisma/Postgres feature would I use for this? Full-text search?

Prisma format fails with disambigious relations

Hey all, not sure if this is my own error here. But I've got the below schema that fails to get formatted by prisma format. I've got quite a few relations setup on a user model. However, running prisma format fails when trying to insert the relations onto the user model. I've added both the errpr and my source schema below. It seems like prisma format fails to name the ambigious relations on the user model. ```model ListingApplication { id String @id @default(cuid()) description String?...

Database Design for Sitemaps

Hi guys, im thinking to store crawled sitemaps in mysql as JSON. is this a crazy idea? Each sitemap be can be quite large and we need to basically diff them every day. How should i think about storing them? Especially at MVP stage?...
No description

Can composite type contain a list of another composite type?

i am trying to define a composite type Token as below, which will contain a list of another composite type Chain, is this valid? i don't see any documentation saying if this is valid or not. ``` type Token { id String symbol String...

Does Prisma ORM support CUIDv2?

Hi, I have a question on the CUID's used in Prisma. I've read the docs and I saw that in the CUID page linked, the project has been deprecated in favor of a CUIDv2. Does Prisma ORM use this new CUID or what are the plans regarding this, if any?...

Bypass accelerate for certain queries to avoid 5MB limit

We have a reporting page that runs 20 or so queries from the db. We want to use accelerate, but 1-2 of the queries exceed 5MB (Not really a way around it). Is there a way, just for these queries, to tell it to just hit the database directly?...

Giving relation implicit name explicitly without dropping table

Hey! So I had a relation between model A and B for a long time now. I haven't named it explicitly. Now I want to add a second relation between the same two models, A and B. To do this, I need to name both relations explicitly, using the @relation attribute. But when I then do prisma db push it informs me that it needs to drop the table "_AtoB", even though that relation table is not empty. Of course, I don't want to do that! But trying to explictily name the table "_AtoB" doesn't seem to help. It still informs me of the same thing. What are my options here?...

Error: spawn prisma-client-py ENOENT

I've been using prisma in node.js & I'm loving it. Right now I have a Fastapi backend that I want to use Prisma with, yet I'm facing this issue whenever I run "prisma db push" : {prisma db push Environment variables loaded from .env...

Additional processing after fetching data

I want to fetch posts from my database but additional scrape the opengraph info from the first link in the post. What would be a good abstraction or approach to do this for every request on this model?

why can't all sides of relation become mandatory? why one of the side has to be optional?

Here's the example. input TextInput? inside TextGeneration model can't be mandatory, otherwise it throws "The relation field text_generation on Model TextInput is required. This is no longer valid because it's not possible to enforce this constraint on the database level.". I have read the docs here (https://www.prisma.io/docs/orm/prisma-schema/data-model/relations/one-to-one-relations#mandatory-1-1-relation) but I don't find any reason for why it has to be optional. Wouldn't that mean TextGeneration may not have a TextInput when it is created? For more context, there foreign key has to be in the TextInput because it is the child model....
No description

many to many api response looks wierd

when for example prisma needs to fetch data that is many to many related for example user & role and then only select roles you will get a api response likee this ``` [...

Prisma breaks lambda

Hey there, I'm new to prisma but fell in love with the database seeding feature immediately. What a time saver and the format tool :chef-kiss: I'm having a problem as you can see from the screenshots that prisma orm as the only dependency makes my .zip deployable file to lambda 3 times the size of the postgres only version breaking my ability to upload the deployable (50MB limit on aws lambda). What is making it so large? ...
No description

Refactoring schema

I have the following schema: ```schema model Invoice { id Int @id @default(autoincrement())...

Extra query into object (GetPayload)

I want to extract this query into an object so I can reuse it in different places. But something is wrong with my UserPostData declaration, because it is missing some fields.
No description

Updating several different data

I'm having a doubt. I have a products table, it has a field called order, which is the order in which the products are displayed. This order field, the user can change, but the problem here is, how do I create a Prisma function that updates, for example, the order field of 5 different products? The only solution that pleases me is to use update with a loop, but I'm not very pleased with it, because the list of products can be large... What's the best way to do this?

Which is more efficient: Promise.all([findUnique() * 3]) or prisma.$transaction([findUnique() * 3])?

With prisma, is it more efficient to do ``` await Promise.all([ prisma.product.findMany()...