From 40bcfb7edc54b4f83e79674ce050361743deaa46 Mon Sep 17 00:00:00 2001 From: chenos Date: Tue, 22 Dec 2020 17:28:30 +0800 Subject: [PATCH] fix: remove through.updateAssociations --- packages/database/src/model.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/database/src/model.ts b/packages/database/src/model.ts index dfa8c94172..1d98e29e38 100644 --- a/packages/database/src/model.ts +++ b/packages/database/src/model.ts @@ -456,9 +456,11 @@ export abstract class Model extends SequelizeModel { const ThroughModel = (association as BELONGSTOMANY).getThroughModel(); const throughName = (association as BELONGSTOMANY).getThroughName(); + for (const { item, target } of belongsToManyList) { const throughValues = item[throughName]; - if (typeof throughValues === 'object') { + console.log({ThroughModel: ThroughModel.options, throughName, item, throughValues}) + if (throughValues && typeof throughValues === 'object') { const { foreignKey, sourceKey, otherKey } = association.options; const through = await ThroughModel.findOne({ where: { @@ -468,7 +470,8 @@ export abstract class Model extends SequelizeModel { transaction }); await through.update(throughValues, opts); - await through.updateAssociations(throughValues, opts); + // TODO:有 BUG,未知 + // await through.updateAssociations(throughValues, opts); } } }