Is it possible to abstract join, (and possibly filter, and select logic) into dedicated functions? #4451
Unanswered
dessalines
asked this question in
Q&A
Replies: 1 comment 3 replies
-
The Composing Applications Guide contains examples and explanations how to handle this kind of situations. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a case where I need to build database views, (for example a
PostView
), made up of the same join, and do one of several things with the results of that join.Currently I have to copy-paste the code for the join for all three of these, but I'd really like to be able to abstract this logic into dedicated functions. For example:
The problem I'm having, is that the return type of the join is incredibly complicated (far too complicated to try to work out by hand), and rust-analyzer and clippy only give an output type using diesels internal types, not ones usable in my code base.
Is there any way around this, so that I can re-use the same join? Is there a generic / boxed type so that I can reuse this join elsewhere?
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions