What's the correct way to model one-to-many relationships? #3939
Unanswered
carterhudson
asked this question in
Q&A
Replies: 1 comment
-
There isn't any built-in way for handling one-to-many relationships in SQLDelight like there is in Room. What you describe (joining them manually into your own class) is probably the most straightforward approach to doing this. Depending on what you're modelling, you could also consider writing a |
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'm having a difficult time finding any documentation on how to model one-to-many relationships with SQLDelight, or what kind of support it provides in that area.
With this example from Room, it's obvious to me what kind of support is provided for achieving what I'm looking for. For SQLDelight, not so much.
What's the idiomatic way to do this with SQLDelight? Based on the entities in the Room example, would I get a
User
entity byuserId
, then fetch allPlaylist
entities byuserCreateorId
, then join them manually onto my own objectUserWithPlaylists(user, playlists)
? Does SQLDelight handle this for me in some way I'm unable to find in docs?I saw this thread from a while back, but it didn't really shed any light on my issue.
Beta Was this translation helpful? Give feedback.
All reactions