How to do nested attributes? #292
Unanswered
vishalbalaji
asked this question in
Help
Replies: 2 comments
-
We don't support this just right now. #230 Not sure if we ever can though. I guess I can make it so you can define what to include, but right now I'm kinda opposed to it. |
Beta Was this translation helpful? Give feedback.
0 replies
-
If you make it a 1:n relation it works, which makes sense since there could be multiple providers for each user. Something like this: // Account contains the actual user data, User is only for authentication.
model Account {
id Int @id @default(autoincrement())
email String @unique
createdAt DateTime @default(now())
name String?
authentication User[]
@@map("account")
}
// User authentication table, since multiple providers can be connected to one Account.
model User {
id String @id @default(cuid())
provider_id String @unique
hashed_password String?
accountId Int
account Account @relation(fields: [accountId], references: [id], onDelete: Cascade)
session Session[]
@@map("user")
} Then add |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to create a separate
Profile
table and add that as a nested attribute to theUser
table. I am using the Prisma adapter have setup a one-to-one relationship in my prisma schemas as so:The problem arises when I try to create the user and profile at the same time, as the profile creation requires the
user_id
property for the FK constraint in theProfile
table, which is not available during creation.Does
lucia-auth
support this? I apologize if this is somewhere in the docs already or has been discussed here before.Beta Was this translation helpful? Give feedback.
All reactions