Leonard Filip
12/09/2021, 12:58 PMuuid()
. Having this entity:
model Tag {
id String @id @default(dbgenerated("(uuid())")) @db.Char(36)
name String
description String? @db.Text
slug String
isTopic Boolean @default(false)
articles Article[]
}
When trying to insert a row via Prisma Studio (or via a prisma.tag.create
inside seed.ts
), I get this error:
Message:
Invalid `prisma.tag.create()` invocation:
Could not figure out an ID in create
Query:
prisma.tag.create(
{
data: {
name: "science",
description: "science description",
slug: "science",
isTopic: false,
articles: {
},
},
select: {
id: true,
name: true,
description: true,
slug: true,
isTopic: true,
articles: true,
},
}
I guess Prisma doesn’t see any id and since it is a mandatory field, it throws this. Shouldn’t the dbgenerated
attribute tell Prisma “hey, no need to provide the id upon create, the db will generate it!“?Akshay Kadam (A2K)
12/09/2021, 1:03 PMarticles {}
should be articles: { create: {} }
Leonard Filip
12/09/2021, 1:31 PMAkshay Kadam (A2K)
12/09/2021, 1:34 PMAkshay Kadam (A2K)
12/09/2021, 1:34 PMAkshay Kadam (A2K)
12/09/2021, 1:34 PMAkshay Kadam (A2K)
12/09/2021, 1:34 PMAkshay Kadam (A2K)
12/09/2021, 1:34 PMid String @id @default(cuid())
Akshay Kadam (A2K)
12/09/2021, 1:35 PMdbgenerated
yet