-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Why the 'subQuery' option from findAll() isn't on the documentation? #7865
Comments
Cause it is one of these "only use them if you know what you're doing" options. You can only use them for 1:n relations if you know for sure that your include will only yield one result (because of JOIN or WHERE conditions etc.). That said, if the caveats are documented, I don't see a reason why it shouldn't be documented. |
As I said, if the caveats are documented, I don't see a reason why it shouldn't be documented. Feel free to do a PR |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂 |
Like eduardrock, I only discovered the 'subQuery' option because of a comment buried in a StackOverFlow question. It first took me a while to recognize that Sequelize was using a subquery in the FROM clause. Then, I spent hours wondering why. Scouring the documentation, I couldn't figure it out. "You can only use them for 1:n relations if you know for sure that your include will only yield one result (because of JOIN or WHERE conditions etc.)." An explanation of why and when subqueries are used would be helpful. In my case, I wanted parent.findAll() to include a COUNT and MIN of fields from a child table, in addition to all the parents' other fields. Seems like a situation many people would run across. Looks like a limit I included was causing Sequelize to generate the subquery. I almost gave up and used a separate raw query. Thanks all for your work on Sequelize. It's had a big impact on many projects, including mine. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂 |
Greetings from the future! (?) I've discovered the option because of the linter. Now reading first @felixfbecker comment I think the bug I've found yesterday (not reported yet) with a top-level condition using |
@edu791 hi, ironically we are switching our project from typeorm to sequelize (using sequelize-typescript and type-graphql) due to the insane lack of documentation of typeorm and we are already happy with our decision 😂 |
It's not in the guides part of the documentation but it is present & explained in our jsdoc. Should become visible on the website once we're done with #13914 |
It is part of the API reference now |
No description provided.
The text was updated successfully, but these errors were encountered: