fix: skip records that do not exist (#1084)
This commit is contained in:
parent
15cbad30b4
commit
534faa85cb
@ -6,7 +6,7 @@ import {
|
|||||||
HasOne,
|
HasOne,
|
||||||
Hookable,
|
Hookable,
|
||||||
ModelCtor,
|
ModelCtor,
|
||||||
Transactionable,
|
Transactionable
|
||||||
} from 'sequelize';
|
} from 'sequelize';
|
||||||
import { Model } from './model';
|
import { Model } from './model';
|
||||||
import { UpdateGuard } from './update-guard';
|
import { UpdateGuard } from './update-guard';
|
||||||
@ -443,6 +443,9 @@ export async function updateMultipleAssociation(
|
|||||||
const instance = await association.target.findByPk<any>(item[pk], {
|
const instance = await association.target.findByPk<any>(item[pk], {
|
||||||
transaction,
|
transaction,
|
||||||
});
|
});
|
||||||
|
if (!instance) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const addAccessor = association.accessors.add;
|
const addAccessor = association.accessors.add;
|
||||||
|
|
||||||
await model[addAccessor](item[pk], accessorOptions);
|
await model[addAccessor](item[pk], accessorOptions);
|
||||||
|
Loading…
Reference in New Issue
Block a user