fix: skip records that do not exist (#1084)

This commit is contained in:
chenos 2022-11-14 14:43:03 +08:00 committed by GitHub
parent 15cbad30b4
commit 534faa85cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@ import {
HasOne,
Hookable,
ModelCtor,
Transactionable,
Transactionable
} from 'sequelize';
import { Model } from './model';
import { UpdateGuard } from './update-guard';
@ -443,6 +443,9 @@ export async function updateMultipleAssociation(
const instance = await association.target.findByPk<any>(item[pk], {
transaction,
});
if (!instance) {
continue;
}
const addAccessor = association.accessors.add;
await model[addAccessor](item[pk], accessorOptions);