charley
charley
PPrisma
Created by charley on 6/2/2024 in #help-and-questions
Why can't I access profile in user? (ORM) (Postgres)
With these models:
model User {
id Int @id @default(autoincrement())
email String @unique
profile Profile?
}

model Profile {
id Int @id @default(autoincrement())
userId Int @unique
user User @relation(fields: [userId], references: [id])
}
model User {
id Int @id @default(autoincrement())
email String @unique
profile Profile?
}

model Profile {
id Int @id @default(autoincrement())
userId Int @unique
user User @relation(fields: [userId], references: [id])
}
I can't access a user.profile and it doesn't exist in the User interface
7 replies
PPrisma
Created by charley on 6/2/2024 in #help-and-questions
Is it bad practice to depend on the unique constraint while creating a new object?
In my example: I have a User model with unique email. Should I be checking beforehand if the email already exists or does it not really matter because it will throw an error?
17 replies