Questions tagged [prisma2]

For questions about Version 2 of the Prisma ORM

232 questions
0
votes
1 answer

How to populate relation of already populated relation?

I have picked prisma2 as ORM for my new project. I run into one consideration, how could I load relation of relation? For example I have such table definitions: model Brand { id Int @id @default(autoincrement()) name String @unique …
LuckyLuke
  • 1,028
  • 2
  • 14
  • 28
0
votes
0 answers

invalid Prisma.create() invocation

im trying to make a web app where I can create projects and inside those projects add requirements. Im good on the creating projects part but im having issues creating requirements for each project, maybe you guys can give a hand with this.. This is…
josedguti
  • 41
  • 1
  • 4
0
votes
1 answer

How to update a many to many relationship in Prisma?

I am modelling a boxing tournament. Boxers and Fights have a many-to-many relationship: A Boxer has many Fights A Fight has many Boxers (exactly 2) Here are the models in the schema model Fight { id Int @id @default(autoincrement()) …
grabury
  • 4,797
  • 14
  • 67
  • 125
0
votes
1 answer

How to update many-to-one relation?

My schema looks like this model Article { id String @id title String isPublished Boolean @default(false) comments Comment[] } model Comment { id String @id content String articleId String article Article…
Ngọc Nguyễn
  • 339
  • 4
  • 16
0
votes
1 answer

How can I Migrate without 'NULL values' in Prisma Client

Good day all, can you help figure this out, I am getting an error that ‘cannot be executed’ even after running npx prisma generate as well as npx prisma migrate dev. If the question mark "?" is removed and I try 'migrating' the errors I am getting…
Chrissy
  • 45
  • 2
  • 6
0
votes
1 answer

What is the correct way to name relations in Prisma? Are there guidelines or conventions I should follow?

I have a User model which can post Comments and vote on them. Comments can also be parented to each other (for nested comments like on HN or Reddit`). model User { [...] // Comments the user has posted comments Comment[]…
lumenwrites
  • 1,287
  • 4
  • 18
  • 35
0
votes
1 answer

how can i set relations in this problem that comment can have many repliy

Error validating model "Comment": Ambiguous self relation detected. The fields comment and Comment in model Comment both refer to Comment. If they are part of the same relation add the same relation name for them with @relation(). model…
0
votes
1 answer

Prisma 2 not working well with NestJS spec testing

I'm playing with NestJS, and setting it up with Prisma 2. My issue as of now is with testing. My failed tests are all to do with the entity object not existing in the PrismaService. For example, every single failed test looks like this, but maybe a…
0
votes
1 answer

Prisma migrate dev: Run command while connected to DB?

Context: Our staging and production postgres databases are in a managed SQL service. Is it recommended to create a local postgres database to run the command the npx prisma migrate dev? Once the migration files are generated (as a result of running…
Suparna Gharpure
  • 391
  • 3
  • 10
0
votes
1 answer

updateMany can't find argument

I have a query: createNotification: async (_, args, {req, res}) => { const followedBy = await prisma.user.updateMany({ where: { following: { some: { id: req.userId }, }, }, …
Peter Boomsma
  • 8,851
  • 16
  • 93
  • 185
0
votes
1 answer

How to import Prisma model in prisma-offset-pagination

I am using a package prisma-offset-pagination to apply pagination. For this I have to use Prisma Model in my code, how is that possible: Check line: 02 const result = prismaOffsetPagination({ model: user, // How to access prisma model like in…
Ibad Shaikh
  • 2,704
  • 3
  • 15
  • 27
0
votes
1 answer

One to many relationships with Self on Prisma

I'm trying to implement a tinder-like simple app with Prisma where a user can swipe left and right to like or dislike another user, and after that, I was to be able to fetch the matches and the candidates. The matches are all users that also like…
Riccardo
  • 51
  • 1
  • 1
  • 7
0
votes
2 answers

findFirst query shows irrelevant data in prisma 2

I want to query a post with id, slug, username, userId params. at least one of the param value are exists in the queries. Not required all of one. const post = await prisma.post.findFirst({ where: { OR: [ { AND: [ …
Ikram Ud Daula
  • 1,213
  • 14
  • 21
0
votes
1 answer

Prisma Client creates new instances

I am using Apollo Server Express and Prisma ORM on my backend. I have created just one prisma instance and put it on graphql context and i am using this prisma instance on my resolvers. import { PrismaClient } from '@prisma/client'; const prisma =…
bomi
  • 113
  • 2
  • 11
0
votes
1 answer

Re-create related records on update

I want to re-create some related records on update, something like this: db.post.update({ where: { id: 1 }, data: { title: "The first post", comments: { set: [{ content: "foo"}, { content: "bar" }], }, }, }) This is…
medihack
  • 16,045
  • 21
  • 90
  • 134