Is it neccessery to have Account model for Users model

I've been seeing this kind of pattern for Prisma's schemas. And wanted to know is this really necessary is this some standard that has some benefits that i don't see.
model User {
id String @id @default(cuid())
email String @unique
password String
fname String
lname String
roles Role[] @default([USER])
reservations Reservation[]

@@index([id])
}
model User {
id String @id @default(cuid())
email String @unique
password String
fname String
lname String
roles Role[] @default([USER])
reservations Reservation[]

@@index([id])
}
4 Replies
arcanereinz
arcanereinz•2y ago
You don't need to have User and Profile separate since it looks like a 1:1 mapping. Only reason to have them separate is if you update User table often and don't want to lock up the Profile table or vice-versa. Although I'm not sure why you have password as a field since usually passwords are never stored only the salt and hashes are stored.
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
arcanereinz
arcanereinz•2y ago
You're right I forgot you're using an orm. You can use a view and have Prisma map the view to an object to reduce the select repetition. I can see how User and Password are separate since you can put different permissions on the sql side to lock down any access.
Sybatron
SybatronOP•2y ago
Thanks for the explanation I haven't figured out how to do auth in react 😅 yet or with what But yeah i know we save only hash I will probably update to having password model
Want results from more Discord servers?
Add your server