我正在尝试清理数据库以运行所有测试,但是我得到一个错误,即通过“ through”与belongsToMany关联创建的关系不存在...
测试文件示例:
before(async () => {
await Promise.all(
Object.values(sequelize.models).map(model =>
model.destroy({ truncate: { cascade: true }, force: true })
)
);
});
错误:
SequelizeDatabaseError: relation "TableExample" does not exist
因此,
Table.belongsToMany(models.Table2, { through: 'TableExample' });
谢谢!