Questions tagged [prisma2]

For questions about Version 2 of the Prisma ORM

232 questions
2
votes
1 answer

Generated types in Prisma do not have optional fields as defined in the schema

Using Prisma v 3.8.1 My User Model is model User { id Int @id @default(autoincrement()) createdAt DateTime? @default(now()) email String @unique name String …
2
votes
1 answer

Prisma many to many self relation error due to @relation and generated type input

Using Prisma 3.7.0. I'm following this example in the docs model Person { id Int @id @default(autoincrement()) name String? followers Follows[] @relation("follower") following Follows[] @relation("following") } model…
shmuels
  • 1,039
  • 1
  • 9
  • 22
2
votes
2 answers

How can I leverage Prisma's implicit relations to create the following relation? (one-many, many-many, one-one)

I'm learning Prisma, I want to leverage Prisma's Implicit relations as much as possible for the following relation (and later I want to use nexus for writing queries): 1 User can belong to Many Conversations (as it's participant) 1 Conversation…
2
votes
3 answers

Prisma 'set' with explicit many-to-many relation?

As in this document of Prisma, set can be used to override the value of a relation. const user = await prisma.user.update({ where: { email: 'alice@prisma.io' }, data: { posts: { set: [{ id: 32 }, { id: 42 }], }, }, }) But when I…
Ngọc Nguyễn
  • 339
  • 4
  • 16
2
votes
2 answers

Prisma splice Item from Array

I have been pushing updates to an array and was wondering if there is a built-in method to remove an entry from the array as well. Basically reversing the push command. I suspect that I have to query all documents and remove the item myself. But…
André Kuhlmann
  • 4,378
  • 3
  • 23
  • 42
2
votes
1 answer

How to add "ON UPDATE" to column definition in prisma schema?

I want to create column with the following definition updated_at TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE now(), But when I type in schema.prisma updated_at DateTime @updatedAt @db.DateTime(0) Then I obtains table…
Daniel
  • 7,684
  • 7
  • 52
  • 76
2
votes
2 answers

Prisma delete many to many relationship with Composite Key

I have this schema here: model label { title String @id @db.VarChar(16) color String @db.VarChar(16) labelplaylist labelplaylist[] } model labelplaylist { playlistId Int labelId String …
Benni
  • 554
  • 2
  • 8
  • 19
2
votes
3 answers

Prisma.js - How to insert into table that has many-to-many relationship

How can I assign some tags to the post using Prisma.js? I have some tags already and I want to assign some tags to the post? I don't want to create a new tag. schema.prisma: model Post { Id String @id @default(uuid()) …
x19
  • 8,277
  • 15
  • 68
  • 126
2
votes
4 answers

Prisma.js: We found changes that cannot be executed

I've used prisma.js as an ORM in my project. After executing the npx prisma migrate dev --name rename_and_add_some_columns, I got this error: We found changes that cannot be executed Error Details: Step 1 Added the required column CategoryId to…
x19
  • 8,277
  • 15
  • 68
  • 126
2
votes
0 answers

Prisma: filtering and count in 1-N relationship

model DataProvider { id Int name String applications Application[] @@map("data_providers") } model Application { id Int name String data_provider_id Int running …
Webman
  • 1,534
  • 3
  • 26
  • 48
2
votes
1 answer

Upgrade Prisma 1 to Prisma 2 with Apollo + GraphQL

I have a problem upgrading from Prisma 1 to Prisma 2. The documentation is quite complicated for me. I currently have a small project using : "dependencies": { "bcryptjs": "2.4.3", "graphql-yoga": "1.18.3", "jsonwebtoken": "8.5.1", …
2
votes
0 answers

start ids at an arbitrary number in prisma data model

Say one has a prisma data model specified like this // schema.prisma model Transaction { id Int @id @default(autoincrement()) // other stuff... } What if one wanted to start the ids at some arbitrary number? After looking at the prisma reference…
fingia
  • 504
  • 7
  • 20
2
votes
1 answer

findUnique query returns null for array fields

I read the Prisma Relations documentation and it fixed my findMany query which is able to return valid data but I'm getting inconsistent results with findUnique. Schema model User { id Int @id @default(autoincrement()) fname …
Ani T
  • 65
  • 2
  • 6
2
votes
1 answer

Convert Object to Object where A is contained in T

I'm working with Prisma to generate schemas and models for my database data. There, I define a "User" model, which has this data (the type is automatically generated by Prisma): type User { name: string, nickName: string, sensitiveInfo1:…
Teodoro
  • 1,194
  • 8
  • 22
2
votes
1 answer

Where did Prisma took my name from when generating the migration README?

I'm starting to work with this amazing toolkit and noticed that when I generate migration files Prisma also creates a README file alongside the new schema. This file happens to have my personal name in the subtitle: This migration has been generated…
Teodoro
  • 1,194
  • 8
  • 22