Luis Cardoso
07/24/2021, 4:40 PMUnique constraint failed on the fields: (`id`)
this is my service:
async createTask(
createTaskDto: Prisma.TaskCreateInput,
user: User,
): Promise<Task> {
return this.prismaService.task.create({
data: {
...createTaskDto,
user: {
create: user,
},
},
});
}
and here is my db schema:
model Task {
id String @id @default(uuid())
title String @db.VarChar(20)
description String @db.VarChar(200)
status TaskStatus @default(OPEN)
user User @relation(fields: [userId], references: [id])
userId String
}
model User {
id String @id @default(uuid())
email String @unique
name String?
password String
tasks Task[]
}
I’m don’t know what is wrong, maybe I’m not getting how the relations work in Prisma. Can someone help me?Luis Cardoso
07/24/2021, 4:59 PMfindMany
I have to pass the ìncludes
option