Skip to content
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 As on Properties of Associated Bs But Still Return all Bs Associated to the Resulting A's #17301

Open
4 of 8 tasks
clemsonfan101 opened this issue May 2, 2024 · 0 comments
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.

Comments

@clemsonfan101
Copy link

Issue Creation Checklist

  • I understand that my issue will be automatically closed if I don't fill in the requested information
  • I have read the contribution guidelines

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?

  • No. This feature is relevant to Sequelize as a whole.
  • Yes. This feature only applies to the following dialect(s):

Would you be willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I will need guidance.
  • No, I don't have the time, but my company or I are supporting Sequelize through donations on OpenCollective.
  • No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in implementing my feature.

Indicate your interest in the addition of this feature by adding the 👍 reaction. Comments such as "+1" will be removed.

@clemsonfan101 clemsonfan101 added 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. labels May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

1 participant