I am using postgres with Prisma in my nodejs project.
I have a prisma model with the below schema
model ParentObject {
parent_object_iid String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
ChildObjects ChildObject[]
SiblingObjects SiblingObject[]
}
When I execute
parentAccount = await prisma.parentAccount.create({ data: {} });
or
parentAccount = await prisma.parentAccount.create({});
I expect an empty record created with a unique random UUID generated and returned. But this does not create any new record but returns the first record in the table.
Is there a different method I need to be using like await prisma.parentAccount.createRecordWithNoData()
It works if the schema is
model ParentObject {
parent_object_iid String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
ChildObjects ChildObject[]
SiblingObjects SiblingObject[]
name string
}
and executing
parentAccount = await prisma.parentAccount.create({ data: {name: 'john doe'} });