Filter As on Properties of Associated Bs But Still Return all Bs Associated to the Resulting A's #17301
Open
4 of 8 tasks
Labels
pending-approval
Bug reports that have not been verified yet, or feature requests that have not been accepted yet
type: feature
For issues and PRs. For new features. Never breaking changes.
Issue Creation Checklist
Feature Description
Describe the feature you'd like to see implemented
I want to be able to findAll cases of an object A (that can be associated to many object B's), that have at least one associated object B where
B.someproperty = "somevalue"
, but I also want to include all Bs associated to the resulting As even if they don't match the where statement (B.someproperty = "somevalue"
). As in, I want to filter A's on B's without effecting the include.I've come across several cases in the past where I need to find all cases of an object A that have an associated object B with some property, but I still need all of the B's associated to the A's that were returned to be included in the results. This usually results in either finding all A's, and then filtering on the server, or finding all A's that have a B with the given property, and then fetching the rest of the Bs later on the server. Neither is particularly ideal.
As you know sequelize already supports filtering A's on B's just fine, but it also filters the resulting B's included in the result set. I'm imagining using it something like the below.
Describe why you would like this feature to be added to Sequelize
It makes sense to do this at query time where possible rather than coordinating and running sequential queries on the server.
Is this feature dialect-specific?
Would you be willing to resolve this issue by submitting a Pull Request?
Indicate your interest in the addition of this feature by adding the 👍 reaction. Comments such as "+1" will be removed.
The text was updated successfully, but these errors were encountered: