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
Find Response With Include Contains Join Table #2143
Comments
+1 |
ISSUE SOLVED 👍 👯
I found this here : http://sequelizejs.com/docs/latest/associations#block-11-line-1 |
@cybernadinou Thanks for responding. This solution works but it requires another call to sequlize in order to remove the join table from the returned DAO. As my original comment stated, I was under the impression this was no longer the default behavior. |
@lsiv568 that issue/fix only deals with primary keys when using On master you should be able to use |
@mickhansen Thanks for the reply. adding |
Great |
@lao see below. User.find({
where: {id: userId}, attributes: userFields,
include: [
{model: db.Role, attributes: roleFields, through: {attributes: []}}
]
}); As i'm sure you can figure out |
Thank you jesus. Is this documented anywhere in the documentation? It took me forever to track this down! |
http://docs.sequelizejs.com/en/latest/docs/associations/#belongs-to-many-associations
|
How would this work in N:M (2x belongsToMany) associations? Include does not work but I'm guessing you could pass something similar into user.getProjects({ through: { attributes: ['something'] } })? |
@agchou I totally agree with you. I am currently in the same situation where I use the provided getters and setters from Sequelize but its returning the containing join table as well. I used:
as well as:
But both result in the same issue. |
@agchou @kevinvugts I think you are placing the attributes at wrong place and also making the wrong updates in code as required by the solution.
|
I am using the latest version,
v2.0.0-dev12
, and when I perform afind
with an include the returned JSON contains the join table. Based on #1468 I was under the impression that this was no longer the default behavior. I have a comment at the bottom of issue #1468 which includes more detailed information. Any idea why this is happening?The text was updated successfully, but these errors were encountered: