dataloader-sequelize: .paired missing on belongsToMany association
Hi,
Not sure whether my setup or association definition is off, but it seems to work fine without dataloader-sequelize.
I have the following “user/friends” association:
User.belongsToMany(User, {as: "friends", through: "Friends"});
This works:
const user = await User.findById(1);
const friends = await user.getFriends();
console.log(`You have ${friends.length} friend(s).`);
However, adding dataloader-sequelize to the mix:
dataloaderSequelize(User);
...
...
Yields the following error:
AssertionError: .paired missing on belongsToMany association. You need to set up both sides of the association.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 3
- Comments: 18 (4 by maintainers)
This assertion forces you to set up on both sides. This is very undesirable. E.g.
This assertion requires you to set up the return on Tag, which makes Tag directly tied to Blog. When it shouldn’t have to know about Blog or BlogTag.
I know, I have copied the existing tests and modified the sequelize models.
On Sat, 15 Jun 2019, 20:05 Mick Hansen, notifications@github.com wrote:
Sounds good to me @kfrajtak, PR welcome
ok i think i solved it with this.