refactor: remove associated history on delete

This commit is contained in:
Methapon2001 2024-03-21 17:27:53 +07:00
parent 2141234f31
commit d543bf7f74

View file

@ -336,14 +336,16 @@ export class ProfileFamilyHistoryController extends Controller {
}
}),
...childrenRecord.map(async (v) => {
return await this.childrenHistoryRepo.save(
this.childrenHistoryRepo.create({
...v,
profileFamilyHistoryId: familyRecord.id,
profileChildrenId: children.find((x) => x.id === v.id) ? v.id : undefined,
id: undefined,
}),
);
if (!children.find((x) => x.id === v.id)) {
return await this.childrenHistoryRepo.save(
this.childrenHistoryRepo.create({
...v,
profileFamilyHistoryId: familyRecord.id,
profileChildrenId: v.id,
id: undefined,
}),
);
}
}),
]);