refactor: remove associated history on delete
This commit is contained in:
parent
2141234f31
commit
d543bf7f74
1 changed files with 10 additions and 8 deletions
|
|
@ -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,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}),
|
||||
]);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue