Title
n

Nditah Samweld

06/19/2022, 3:02 PM
How can I make an optional
unique
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")
}
👀 1
h

Harsh Singh

06/20/2022, 7:20 AM
Hey Nditah 👋 Could you maybe elaborate? There's the
?
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.
1
n

Nurul

06/20/2022, 10:09 AM
Maybe also share the query which you are invoking and your expected output
1
1
n

Nditah Samweld

06/28/2022, 3:58 PM
Thank you @Harsh Singh I made the valud null by default at the entity level. It works.
:fast_parrot: 1