-
Notifications
You must be signed in to change notification settings - Fork 24
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
Filter on associations? #55
Comments
Yes, it is. It's just because of how the underlying database works with primary/foreign keys. See this issue: #38. I would be supremely grateful for a contribution. |
As I understand this issue, this will require multiple db calls? |
Perhaps I did not understand you correctly. Are you wanting to filter on a joined table from a given query? In that case, you'll need to base the filter off of that association (or reference it potentially by the relationship key path). I'm happy to consider a particular use case. That might clarify the issue a bit. |
Let's say I have a user & users I want to query various things on the profile as well as the "base query" user table. |
As a non-working example:
Obviously this doesn't work, but I imagine some composition should work. |
@rcdilorenzo Got it working--let me know your thoughts and I'll provide a readme update showing usage of filtering on associations.
|
I imagine Ecto 3 will vastly improve this and allow for dynamic building...but until then, I think this is the only way to accomplish what I'm looking for. |
Excellent! This looks good. If it's possible to simplify parts, I think that would be even better. For example, the following lines could probably be excluded and yet still convey how association filtering can be accomplished: # ...
else
{:error, error} -> {:error, error}
error -> {:error, error}
# ... |
Yeah, I probably won't include that part b/c those tuples are used on my controllers. 😸 I'll send you a PR! (hopefully sooner than later) |
From the documentation, it's difficult to tell how to filter/query on associated records. Is that part of the feature set? If so, I'll be happy to provide some documentation/contribution.
The text was updated successfully, but these errors were encountered: