Prisma

P

Prisma

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

Join

Unable to find table (not available) but it exists

The table (not available) does not exist in the current database. code: 'P2021', clientVersion: '5.7.0', meta: { modelName: 'DraftItem', table: '(not available)' } I can GUARANTEE you that DraftItem exists. Doesn't happen for other tables, happens to multiple devs, seems to work fine once its deployed.. our running app works fine. Its just connecting to the dev database locally that it doesn't work. ...

Did Prisma.raw and Prisma.sql helpers get removed?

I'm working on writing a new extension. In my code, I use the .raw and .sql helpers/methods. For example query = Prisma.raw(`${query1}${query2}`). For Prisma 5.14 this works fine, but not in 5.15.1. I initially found it while updating lint, so thought the Property 'raw' does not exist on type 'typeof Prisma'. error I'm seeing in the IDE may have just been cruft. But, in fact, when testing in a real client, it no longer works: Error: Prisma.raw is not a function. This usage is still i...

Prisma Nuxt RollupError

Hello, I am trying to use @prisma/nuxt, but after installation and when I run npm run dev, it results in the error ```ℹ Vite server warmed up in 3864ms 9:33:51 AM ℹ Vite client warmed up in 5284ms 9:33:52 AM [9:33:52 AM] WARN [plugin inject] node_modules/.pnpm/@prisma+nuxt@0.0.30_magicast@0.3.4nuxt@3.12.2@opentelemetry+api@1.9.0_@parcel+watcher@2.4.1_2uyq5cr4225ns57lx4llpfiydq/node_modules/@prisma/nuxt/dist/runtime/server/utils/prisma.d.ts: rollup-plugin-inject: failed to parse /home/joe/novaint/node_modules/.pnpm/@prisma+nuxt@0.0.30_magicast@0.3.4nuxt@3.12.2@opentelemetry+api@1.9.0_@parcel+watcher@2.4.1_2uyq5cr4225ns57lx4llpfiydq/node_modules/@prisma/nuxt/dist/runtime/server/utils/prisma.d.ts. Consider restricting the plugin to particular files via options.include ...

Random findMany is not a function errors

Sometimes randomly, prisma is throwing an error: prisma.profile.findMany is not a function. Once i restart the application, it starts working, but again after sometime the error comes up I'm using Prisma with NodeJS Express server....

Where is my environment var coming from?

Odd question but I recently changed my SQL provider. In my deployed environment I have an environment var called DATABASE_URL it works fine I updated it and now in my deployed environment I'm pointing to the correct server. In my local host though I have no idea where DATBASE_URL is getting set. I don't have a .env file. I did this 5 months ago but I know I didn't want my database info in my repo. It would make sense that I would create an environment var in my localhost only I don't remember doing so and when I type printenv DATABASE_URL isn't listed. That said when I build my app I get an error saying it can't connect to my old provider so it's getting it from somewhere I have the following in my schema but no idea where I set it - anyone have any ideas? ``` datasource db {...

omit with condition

I want to only omit certain fields if a condition in the same thing I'm querying is true example: ```js const channels = await prisma.channel.findMany({...
Solution:
--- Here is the omitArray function for anyone finding this later ```ts export function omitArray<Data extends object, Keys extends keyof Data>( data: Data[],...

How to cover this custom SQL with Prisma

Hi, i currently use this SQL statement to fetch data and make calculations. Is this also possible without a RAW query? ```sql const result: { id: string;...

length() of column

Hello and good morning. Is there a way to in a query ask for the length of a column to be returned? e.g. in SQL: SELECT length(message) as lng from TABLE; Can this be done except by raw query?...

Unit testing a result extension

Hi, folks! Is there any way whatsoever to unit test a result extension. I started out simple - by just adding a computed field through a result extension - but how do I test it without spinning up an actual integration test? Much obliged! M....

How to populate array in one-to-many relationship (or may be even persist)?

Hi. I have the following example models: ``` model User { id String @id @default(auto()) @map("_id") @db.ObjectId...
Solution:
Okay, I probably found a solution. It seems that restarting Nest.js application helped....

Invalid `prisma.account.findUnique()` invocation:

I am having issues with the google signin redirecting me to http://localhost:3000/api/auth/error?error=AdapterError Here's the error log: ```log [auth][error] AdapterError: Read more at https://errors.authjs.dev#adaptererror...

How can we do arbitrary atomic number operation in prisma?

Something like:
SET avg = (avg + newValue) / (count + 1)
SET avg = (avg + newValue) / (count + 1)
...

Accelerate migration not happening Vercel Prod but does with Vercel Preview

Vercel Preview migration just built and deployed just fine as expected, but Production build does not perform the migration! What? I have DIRECT_DATABASE_URLs specified for both. Using GCP Cloud SQL Postgres. URGENT.

Local sqlite db in monorepo with nextJS trying to find table 'main.TABLE' instead of 'TABLE'

Hi, I'm running a monorepo with my db separate from my NextJS package, and have already implemented the workaround plugin to let it find the external DB. It's my first time trying to get anything to show up, and I'm now getting an error in the frontend: ...

Prisma runtime error using direct db access in parallel with Accelerate on Vercel

I want to use two paths to Postgres: Prisma Accelerate and direct for a very limited use case (mentioned below) with my Next deployment. I get this runtime error on Vercel, not locally:
Error validating datasource `db`: the URL must start with the protocol `prisma://`
Error validating datasource `db`: the URL must start with the protocol `prisma://`
...

Multiple relation between models

Hello guys, I'm creating a marketplace but I have a problem. I have 2 models: User and Post. I want the user to have the fields posts (his own posts) and favoritePosts (the posts he liked). I made this but it doesn't work: ```js...

prisma is generating some crappy migrations for no reason

Hey folks, Can someone guide me why prims is generating some crappy migrations for no reason? I mean why it deletes the constraint ActionDependencyList_pkey and add it again after? ```bash...

Pointing two relations to same field?

I have a scenario where it make sense to store informations about two 1-n relation in one field. I'm wondering if it is even possible to do something like this. Consider this example: ```ts...

Cannot read properties of undefined (reading 'kind')

Hey, i get the following error, when performing a db action. ```...