Questions tagged [prisma2]

For questions about Version 2 of the Prisma ORM

232 questions
1
vote
0 answers

Prisma findMany() - Ordering by count orders 0 count as positive infinity

I am trying to findMany() users and orderBy their post count. I found exactly how to do it in the docs and it works except it counts users with 0 posts as +infinity. orderBy: {posts: {count: asc}} For example, the ordering works in ascending…
TemuujinNat
  • 135
  • 1
  • 1
  • 7
1
vote
0 answers

Prisma how to create multiple references to a data model

I'm having issues on how to seed a relationship of the following: Store -< Product >- category A store can have many products. A Category can have many products. My Issue is trying to seed store/products after category has been already seeded. model…
Mickey Sly
  • 429
  • 2
  • 6
  • 21
1
vote
3 answers

Instantiate prisma only once

I am currently using prisma 2.20.1 on a project running postgres. On their doc they say to import PrismaClient and instantiate it throughout the application. However, coming from other use cases, where you connect to the db only once, feels weird on…
1
vote
2 answers

How to use $transaction API in this scenario?

const a = prisma.user.create() throw new Error() // some error happened const b = prisma.user.create() prisma.$transaction([a, b]) Since an error happened, prisma.$transaction was never called, so a inserted into the database.
刘佳闻
  • 43
  • 1
  • 6
1
vote
1 answer

Graphql Nestjs add arguments to type field

Hello how are you doing, I have been learning Nestjs for the past week and enjoy it a lot. I am currently using it with Prisma 2 to build a graphql server. I want to add arguments in a graphql type field to be able to filter or order the result…
Adriel
  • 183
  • 1
  • 2
  • 11
1
vote
0 answers

Prisma 2 unable to fetch DateTime column with null value

await this.prisma.fee_collections.findMany({ where: whereClauseWithTransactionDateCondition, include: { student_master: { select: { fee_start_month: true, } …
1
vote
2 answers

AWS ECS & Prisma2 & RDS: Connect local machine to private DB for migration with prisma?

I deployed my Full-Stack project to AWS ECS(Docker). Everything is working so far. My problem is that I don't know how to connect my local machine to the RDS-DB to migrate my DB-Schema. I want to run the command: prisma migrate deploy…
Tölz
  • 766
  • 2
  • 8
  • 18
1
vote
1 answer

prisma/codemods doesn't transform findUnique

I just did an update from version 2.10.1 to version 2.15.0. Furthermore I ran "npx @prisma/codemods update-2.12 ./". Then times only the single findUnique transform. However always the same result comes out: PS C:\App\Backend> npx @prisma/codemods…
pasek
  • 347
  • 4
  • 11
1
vote
1 answer

App on vercel fails to connect with AWS RDS

I am facing trouble when my app written using NextJS with PrismaIO as database ORM deployed to Vercel tries to connect with MYSQL database which is hosted on AWS RDS fails due to time out. It shows below error after a while: 502: BAD_GATEWAY Code:…
rohitpaniker
  • 695
  • 1
  • 7
  • 25
1
vote
1 answer

How to search M to N relationship in prisma?

I'm working on project with prisma nowadays. I designed m to n relationship table. Below is my code. schema.prisma model Artists { id Int @id @default(autoincrement()) artistName String? Albums …
lcpnine
  • 477
  • 1
  • 7
  • 16
1
vote
1 answer

How to replace the null values with undefined (in object properties) only in case of not assignable types?

type GraphQLInput = { email: string; age?: null | number | undefined; height?: null | number | undefined; } type PrismaPerson = { email: string; age: number | undefined; height: null | number; } let input: GraphQLInput = { email:…
robert.little
  • 410
  • 3
  • 13
1
vote
0 answers

Prisma 2 efficient ManyToMany query for users with roles

I have several tables, User ---> UserRoles <--- Roles in which I want to query all the users and get all the users roles in the query also. I can achieve this with plain sql with the following: SELECT u.user_id, u.first_name, r.description ... FROM…
Dreamystify
  • 125
  • 13
1
vote
0 answers

How do you create many records at once using Prisma2?

I'm new to Prisma 2 and I'm wondering how do I create many records using the prisma client? It doesn't seem to have any documentation around this use case, but there are docs for updateMany.
Kevin He
  • 871
  • 7
  • 18
1
vote
1 answer

Export server-side Prisma models for client-side usage

Is there any automated way to export the type definitions of my models generated with prisma generate but without the database CRUD methods? Then I could export them as a model module and use type definitions on client-side.
Teodoro
  • 1,194
  • 8
  • 22
1
vote
1 answer

Multiple relations between models

I am struggling to understand how to build multiple relations between two models. Take the following: model User { id Int @default(autoincrement()) @id goalBoard GoalBoard[] ... } model GoalBoard { id Int …
Kayote
  • 14,579
  • 25
  • 85
  • 144