Node.js 如何在Sequelize中删除m:n关联表中的所有寄存器?

Node.js 如何在Sequelize中删除m:n关联表中的所有寄存器?,node.js,sequelize.js,Node.js,Sequelize.js,我有两个模型通过一个表具有m:n关联,我想删除这两个模型之间的所有关联。 要添加关联,我可以执行以下操作: //just for example, imagine that a1, b1 and b2 are instances of models A and B //and they association are made through table AB a1.addB(b1); a1.addB(b2); // or a1.setB([b1,b2]); 现在我在表AB中有一个寄存器

我有两个模型通过一个表具有
m:n
关联,我想删除这两个模型之间的所有关联。
要添加关联,我可以执行以下操作:

//just for example, imagine that a1, b1 and b2 are instances of models A and B
//and they association are made through table AB
a1.addB(b1);  
a1.addB(b2);
// or
a1.setB([b1,b2]); 
现在我在表AB中有一个寄存器,它将
a1
b1
关联,另一个寄存器将
a1
b2
关联

我的问题是:如何删除表
AB
a1
B
寄存器之间的所有关联?
我不想删除de
a1
寄存器,只需将其与
B
解除关联即可

我尝试这样做:

a1.set(); 
但它尝试在表
AB


更新:有一个关于
a1.removeB(b1)的续集
工作?@doublesharp此操作将删除将
b1
a1
关联的寄存器。我想要的是从
a1
中删除所有关联。。。我知道我可以查询所有关联,然后删除它,但我想知道是否有更好的方法来实现这一点。。比如:
a1.removeAllB()
如果你想在一个查询中完成它,最好的选择可能是一个原始SQL查询,我不知道用Sequelize的sugar实现它的方法。另一个选择是编写一个
instanceMethod
为你做这件事,以
模型
为参数。可能有助于为项目做出贡献。对此有任何更新或解决方法吗?我在找完全一样的东西