-
-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Model relationship joins #662
Comments
This would be huge for me as well. I'm usually just writing custom |
@cycomachead if possible, the preferred approach to load data is to use preload Does |
To be honest, it might, but I couldn't quite get it right the first couple tries. In the main case, I have a "has-many-through" relationship, much like the OP. in this case I want to be able to write |
@cycomachead Can you show me an example of your fetch function? |
Sure, in this case I ended up using a subquery, but could have written a join. I didn't test which would be ore performant... |
I just found a way to solve this kind of situations, indeed lapis model system is very nice in this regard, i do not use lua or moonscript but the following code in fennel lets me retrieve a user, its posts, and its colors, which are a many to many relationship with a table in the middle user_colors: (app:get "/users"
(fn []
(let [user (Users:find "1")
posts (user:get_posts)
colors (user:get_user_colors)]
(each [i v (ipairs colors)]
(v:get_color))
{:json {: user }}))) I find it easier and more powerful than django rest framework serializers, very awesome leafo. |
As discussed on Discord yesterday, I would like to see the ability to model joins via relations at some point. I am posting this issue so I can keep track of it in my code~
My main use case at the moment would be to select a list of
events
from the database through aplayer
object using theregistrations
table as a filter.Players
Events
Registrations
The text was updated successfully, but these errors were encountered: