Akshay Kadam (A2K)
11/25/2021, 9:58 AMProperty 'settings' is missing in type '{ id: string; name: string; username: string; }' but required in type 'UserCreateInput'.ts(2322)
but I have set the default values in settings
but it is not optional.
How do I fix it?
My schema:
model User {
id String @id @default(cuid())
username String @unique
name String?
email String? @unique
image String?
// relations
settings Settings @relation(fields: [settingsId], references: [id], onDelete: Cascade)
teams Team[]
settingsId String
}
model Settings {
id String @id @default(cuid())
timezone String @default("UTC")
// relations
user User[]
}
Ryan
11/25/2021, 1:23 PMsettings
is required in user, only the ID in the Settings
model has a default value. You still need to pass settings: { create: {} }
when creating a user.
To make settings
optional, use a ?
so that it’s not required when creating a user.Akshay Kadam (A2K)
11/25/2021, 1:56 PMtimezone
also has a default
value so maybe it's for relation user
for which it is required?Ryan
11/25/2021, 2:15 PM