Relating User Data to Another Table #653

Closed
opened 2026-03-13 07:59:01 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @aether6430 on GitHub (Feb 11, 2025).

I'm working with Better-Auth and need to associate additional data with my users, stored in a separate table. I'm trying to figure out the best way to create a relationship between the User data managed by Better-Auth and this other table.

Is there currently a supported method, or recommended approach, for achieving this? I'm not sure what the best practice is within the context of Better-Auth.

Any guidance or suggestions you can provide would be greatly appreciated.

Thanks in advance for your time and help.
Aether

Originally created by @aether6430 on GitHub (Feb 11, 2025). I'm working with Better-Auth and need to associate additional data with my users, stored in a separate table. I'm trying to figure out the best way to create a relationship between the User data managed by Better-Auth and this other table. Is there currently a supported method, or recommended approach, for achieving this? I'm not sure what the best practice is within the context of Better-Auth. Any guidance or suggestions you can provide would be greatly appreciated. Thanks in advance for your time and help. Aether
Author
Owner

@Bekacru commented on GitHub (Feb 11, 2025):

You can add additional field for the referencing field and to return the additional table information on a session you can use custom session

@Bekacru commented on GitHub (Feb 11, 2025): You can add additional field for the referencing field and to return the additional table information on a session you can use [custom session ](https://www.better-auth.com/docs/concepts/session-management#customizing-session-response)
Author
Owner

@aether6430 commented on GitHub (Feb 11, 2025):

Ohh thanks a lot! But I was aiming for a many-to-many relation type thing. Like my user will have multiple courses attached to it and the course will have multiple users attached to it

@aether6430 commented on GitHub (Feb 11, 2025): Ohh thanks a lot! But I was aiming for a many-to-many relation type thing. Like my user will have multiple courses attached to it and the course will have multiple users attached to it
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#653