You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
load only certain field attributes when eager loading belongsToMany? #3258
When I eager load belongsToMany, sequelize will return the join table along with the attributes. I would like just the attributes I specify. How can this be achieved? For example,
user
belongsToMany(models.group, {through: "rosters", as: "clubs"});
group
belongsToMany(models.user, {through: "rosters": as: "members"});
where rosters will contain fields in the join table (userId, groupId, etc...).
I would just like to list a user's group names without having to return the join table too. I'm not sure if this matters, but I'm not defining an actual model for the join table. I just called it rosters for the table name.
Activity
mickhansen commentedon Mar 3, 2015
You should be able to do
include: [{model: .. through: {attributes: []}}]psabharwal123 commentedon Oct 8, 2017
@mickhansen how would i do this for a 'belongsTo' association?
bidiu commentedon Oct 14, 2017
Same question here: what if the relation is 1 to m?