parent为参照表,children外键关联parent。
const parents = await this.ctx.model.Parent.findAll({
where: { id: parents_id },
include: [{
model: this.ctx.model.Children,
as: 'children',
}],
});
for (const parent of parents) {
for (const child of parent.children) {
child.destroy();
}
parent.destroy();
}