Question
Answer
You can make the field 'phone' nullable by adding a question mark '?' after the field's data type declaration. To make it default to null instead of undefined, set the field's default value as null at the entity level. PostgreSQL guarantees uniqueness even for null fields but not for undefined values. Additionally, it would help to include the query being invoked and the expected output for better assistance.
Nditah Samweld
06/19/2022, 3:02 PMunique
input field phone
NULL
instead of "`undefined`" for missing input.
PostgreSQL guarantees uniqueness even for NULL
fields but not for undefined
values.
model User {
id String @id @default(cuid())
email String @unique
phone String? @unique
@@map(name: "user")
}
Harsh Singh
06/20/2022, 7:20 AM?
if you need to make anything optional, but I see you've already added that. For making something null instead of undefined, just pass in phone number as null when you're creating it.Nurul
06/20/2022, 10:09 AMNditah Samweld
06/28/2022, 3:58 PM