Questions tagged [prisma]

Prisma is a next-generation Node.js and TypeScript ORM for PostgreSQL, MySQL, SQLite, CockroachDB, MongoDB and SQL Server.

Prisma is a next-generation ORM and can be used in any Node.js or TypeScript backend application (including serverless applications and microservices). This can be a REST API, a GraphQL API a gRPC API, or anything else that needs a database. Use the Prisma client to access your database with Node.js, TypeScript or Go.

Prisma features:

  • An auto-generated and type-safe client library
  • Declarative data modeling and migration system with Prisma Migrate
  • Beautiful data management workflows with Prisma Studio
3236 questions
17
votes
8 answers

Prisma Schema not updating properly after adding new fields

As the title states, I am using Prisma 2 in a Next JS app. I have a very simple schema: model User { id Int @id @default(autoincrement()) firstName String middleName String? firstLastname String secondLastname…
Isaac
  • 171
  • 1
  • 1
  • 7
16
votes
3 answers

Unknown binaryTarget debian-openssl-3.0.x and no custom binaries were provided error Command failed with exit code 1

Is there any way I can solve this problem? I recently updated to Ubuntu 22.04 Getting the problem while using Prisma.I can't run my project. I have use "@prisma/client": "2.20.1" Error: Unknown binaryTarget debian-openssl-3.0.x and no custom…
Shohedul
  • 163
  • 1
  • 6
16
votes
2 answers

WebSocket connection to 'ws:/_next/webpack-hmr' failed: WebSocket is closed before the connection is established

Hi am having this problem, i try to make subscriptions with graphql in nextjs, but something is wrong and i dont have any idea how fix it. I am having websocket error - "WebSocket connection to 'ws:/_next/webpack-hmr' failed: WebSocket is closed…
16
votes
6 answers

Get User ID from session in next-auth client

I'm using next-auth with Prisma and Graphql, I followed these instructions to set up the adapter and my models accordingly: https://next-auth.js.org/adapters/prisma Authentication works but when I inspect session object from here : const { data:…
Ivditi Gabeskiria
  • 302
  • 1
  • 2
  • 9
15
votes
1 answer

Typescript circular reference when testing prisma with jest-mock-extended

I started writting tests revolving around prisma(v3.6.0) usage in my application. To do so I followed the official prisma page Unit testing with prisma and I am using jest-mock-extended. My issue is that I have a typescript error when using the…
Yabada
  • 1,728
  • 1
  • 15
  • 36
15
votes
5 answers

Prisma many-to-many relations: create and connect

In my Prisma schema, I have a many-to-many relationship between posts and categories. I've added @map options to match the Postgres snake_case naming convention: model Post { id Int @id @default(autoincrement()) title …
Johnny Oshika
  • 54,741
  • 40
  • 181
  • 275
15
votes
1 answer

Nexus Prisma - How to handle createdAt and updatedAt with crud globally?

First thing I came up with, is by calling computedInputs in the nexusPrisma option. But it won't work since they need to be handled differently depending on the situation, but globally: 1. create -> createdAt = now, updatedAt = null 2. update ->…
Eliya Cohen
  • 10,716
  • 13
  • 59
  • 116
15
votes
2 answers

Ordering by multiple columns in Prisma

I know currently Prisma doesn't support ordering by multiple scalars fields, (see this issue: https://github.com/prisma/prisma/issues/62). But, I'm wondering if there is someone who found a solution to work around this issue without using executeRaw…
Andrei Bacescu
  • 569
  • 1
  • 5
  • 11
14
votes
1 answer

Use prisma generated types with swagger nestjs

I am using nestjs with prisma and swagger. When I use import {PrismaGeneratedType} from '@prisma/client'; ... @ApiOkResponse({type: PrismaGeneratedType}) in a controller if gives error: 'PrismaGeneratedType' only refers to a type, but is being…
Ahmed Nawaz Khan
  • 1,451
  • 3
  • 20
  • 42
14
votes
1 answer

Can't make two 1:1 relations in one model in Prisma. Ambiguous relation detected

I'm trying to make two 1:1 relations in one model in Prisma ORM, but got following error: Error validating model "Person": Ambiguous relation detected. The fields placeOfBirth and placeOfDeath in model Person both refer to Place. Please provide…
13
votes
5 answers

How to split Prisma Model into separate file?

I'm learning Prisma ORM from video tutorials and official docs. They are explain and write All model code in one file called schema.prisma. It's ok but, when application grow it became messy. So, how should I separate my Model definition into…
Hasibur Rahman
  • 641
  • 2
  • 7
  • 18
13
votes
1 answer

Why "null" can't be the default value of a nullable column?

Consider this schema: model Comment { id Int @id @default(autoincrement()) reply Comment? @relation(fields: [replyId], references: [id], onDelete: SetNull) replyId Int? @default(null) comment String } Here both…
Arman
  • 720
  • 2
  • 7
  • 18
13
votes
2 answers

Prisma $queryRaw with variable length parameter list

I am using Prisma with Postgres. I need to use $queryRaw for a particular query due to use of unsupported tsvector type in the underlying table. In this query, I also need to use an 'in' statement where the items in the 'in' list need to be…
Michael Dausmann
  • 4,202
  • 3
  • 35
  • 48
13
votes
2 answers

Querying NOT NULL GraphQL with Prisma

Schema: type TrackUser { id: ID! @unique createdAt: DateTime! user: User #note there is no `!` } type User { id: ID! @unique name: String! @unique } I want to get Alls TrackUser where User is not null. What would be the query?
Alan
  • 9,167
  • 4
  • 52
  • 70
12
votes
6 answers

Supabase client permission denied for schema public

Whenever I've try to use @supabase/supabase-js to query the db, I get an error. error: { hint: null, details: null, code: '42501', message: 'permission denied for schema public' } I think it has something to do with Prisma, which I…
rdavis
  • 143
  • 1
  • 1
  • 5