Prisma

P

Prisma

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

Join

nested transactions

Hey, i got something like -> prisma.transaction(async prisma => { test(1) test(2) ...

Prisma for expo app

Please need help setting up prisma for expo app, i followed the instructions on the github page but keep geeting error meesage. ERROR Error: 🟥 @prisma/react-native failed to initialize, js engine:
hermes. i need step by step setup. thanks...

Invalidating/flushing cache in Accelerate

We're using Accelerate but haven't started using the caching mechanism. From reading the docs, I'm not seeing any obvious way to flush/invalidate cache on the fly. We have some slow queries which we would like to cache, but these queries are used in report generation, so we would want to be able to refresh the cache when new data has been added which changes the report data. What is the recommended approach for achieving this with Prisma Accelerate?

How can I use Prisma with Kubernetes? Any example

I couldn't find a single local development Kubernetes example with Prisma, and like other tools like Skaffold. How can I do that? Prisma is an interesting case because it requires also post processing of migration, deployment and creation of the schemas....

Unique index with nullable composite key?

Is it possible to create a unique composite key where one of the keys is nullable? I have a table where the record is unique if the foreign key is null or has a value but I can't do that in an upsert without Prisma requiring all the keys to have a value.

Multiple one-to-one relations with referential actions

Hey, am I understanding it correctly that this is a limitation of Prisma (or SQL?)? My goal is to have two one-to-one relations but defined on the PaymentParty side to be able to define onDelete: Cascade so the PaymentParty entities get deleted on Payment delete. I tried numerous solutions and the closest to what I'm trying to achieve is to define the scalar relation fields on the Payment side. And that's a viable solution but then I cannot set the referntial action for Payment and would have to delete the parties in code. Payment sender and recipient should of course be required. Any insight on this would be greatly appreciated, thanks!...
No description

Nested queries with mongodb not working.

Hi guys, I have run into a roadblock in my project where I need to fetch some data via my search operation. I have the following relations setup:...
No description

Cannot find environment variables

I've came back to my project from a two week hiatus, and as always I started by bumping the dependencies. However, upon starting the vite dev server, I get prisma errors stating the environment variable is missing. Everything worked before, I haven't changed anything except the dependency bump. Also worth noting that the environment value is there, shown by the attached images. dependency versions: ```patch - "prisma": "^5.15.0"...
Solution:
@SunStorm could you try bumping prisma and @prisma/client to 5.16.1? We believe this was a regression in 5.16.0
No description

N+1 problem with multiple filter conditions

I have a table that maps access to "file groups" per user, for a range of time periods. each group having a different expiry date for each user. Now I want to retrieve all files that a user has ever had access to. for that, the naive approach would be something like...

Preserve key order when writing JSON fields

I am using Prisma with Postgres and I have the following JSON data that I want to insert into my table: {"First Section":[{"title":"Heading 1","body":"Body 1"}],"Second Section":[{"title":"Heading 2","body":"Body 2"}],"Final Section":[{"title":"Heading 3","body":"Body 3"}]} To save it to my database, I'm using upsert: ```...
Solution:
I ended up solving this in a way that didn't require me to have the keys written in a specific order.

Accessing extended operations on the prisma client with typescript

I'm trying to make some abstract types around the Prisma Client, like so: ``` import type { Prisma } from "@prisma/client"; import type { Operation as PrismaOperation } from "@prisma/client/runtime/library"; ...

$queryRaw for Insert asking for id which is set to autoincrement

I've created this: ``` let prisma = new PrismaClient().$extends({ model: { restaurants: {...

Prisma Accelerate and Tracing

Does Accelerate work with Prisma tracing? What shoes up when you do this?

mongodb not updating schema

I'm using Firebase functions with Mongodb (atlas) Let's consider I have a schema like that `generator client { provider = "prisma-client-js"...

Prisma returning different results for the same query (FindMany vs Count)

For some reason our prisma client is returning different results for a FindMany vs a Count.... Any idea how this could be happening? No middleware is attached, so that can't be causing any interference
No description

Update to 5.16 results in Initialization Error

On version 5.15.1 everything works fine but updating to 5.16.0 results in this error attached.
Solution:
5.16.1 patch release just went live: https://github.com/prisma/prisma/releases/tag/5.16.1...
No description

Prisma Pulse issue

My server keeps crashing sometimes after 24hours the recent one was after 40hours and the error messages suggest something to do with prisma pulse
No description

Prisma Error: Error Querying DB due to DB is starting up

So I am building an admin panel that is hosted in railway, since i put my db and app to sleep if it is not used it resulted error in first query since db is starting is longer than app starting. How can I mitigate such error?
No description

Problems when deploying after a failed migration

I ran the test with the following example 1. assuming I have raw data, I created a field called test String and ran prisma migrate dev --name test --create-only. 2. when I ignored the warning and ran prisma migrate dev, a migration error occurred and a failed record was created in _prisma_migrations. 3. followed the official guide and ran deploy after rollback https://www.prisma.io/docs/orm/prisma-migrate/workflows/patching-and-hotfixing#option-1-mark-the-migration-as-rolled-back-and-re-deploy 4. reflected as normal...

What's the proper way for me to define tsvector field in my schema file?

I defined a trigger function that will update the search_data column. I'm not sure how I should define the prisma schema in this case. I'm getting weird result with filtering. For example I have these entries: Apple, Banana, Orange. When I define "data_search" @@ to_tsquery('english', ${searchTerm}) with searchTerm=Orange it returns Orange correctly. But when I'm not doing any where clause, Orange is not returned. Here's the actually model definition: ...