I have a model called User with the following fields –
model User {
id Int @id @default(autoincrement())
email String
password String
name String
tag String
}
Now, the name and tag params are not passed in the inital API when the user is created. But they are mandatory for every user. So how do I go about handling this? So far I have two options in mind.
Option A: Make the fields name
and tag
as optional
. Handle the logic during API calls to make sure they are added before a user can use the app.
Option B: Add @default("def_user_name")
and @default("def_user_tag")
in schema and keep both fields mandatory
.
I dont like Option A because every developer needs to carefully look through to make sure they dont mess up anywhere. I dont like Option B because I have to add logic again to make sure def_user_name and def_user_tag are not actual values the user selects.
What is the best way to deal with this?