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
Many To Many Association Fetch Not Working #3185
Comments
Appears to be a bug, can you log |
[ ....
'created_at',
'updated_at',
'deleted_at',
'id_group',
'id_user' ] the ... are attributes that are not relevant for the issue. (I suppose) |
|
Sure : SELECT "Group"."id_group",
"Group"."group",
"Group"."created_at",
"Group"."deleted_at",
"User_has_Group"."created_at" AS "User_has_Group.created_at",
"User_has_Group"."updated_at" AS "User_has_Group.updated_at",
"User_has_Group"."deleted_at" AS "User_has_Group.deleted_at",
"User_has_Group"."id_group" AS "User_has_Group.id_group",
"User_has_Group"."id_user" AS "User_has_Group.id_user"
FROM "Group" AS "Group"
INNER JOIN "User_has_Group" AS "User_has_Group" ON "Group"."id_group" = "User_has_Group"."GroupIdGroup"
AND ("User_has_Group"."deleted_at" IS NULL
AND "User_has_Group"."id_user" = '6a9d3226-d83c-42dc-8969-af1a92cdca65')
WHERE ("Group"."deleted_at" IS NULL); Thanks for the help |
Hmm, you're hitting a bug i was sure i fixed, for now you can probably work around with: User.belongsToMany(models.Group, {as:'groups', through: models.User_has_Group, foreignKey: 'id_user', otherKey: 'id_group'});
Group.belongsToMany(models.User, {as:'users', through: models.User_has_Group, foreignKey: 'id_group', otherKey: 'id_user'}); |
Thanks ! your work around works. |
@grimabe It should work with what you have, there must be a bug :) |
I am using a many to many association between a user and a group and I got the following error when I want to fetch the groups associated to a user :
Environment :
Here is the code :
User model
Group Model
User_has_Group Model
The code that crash
on the line _user.getGroups().then(function(groups) {_
Thanks for the help
The text was updated successfully, but these errors were encountered: