diff --git a/src/controllers/OrgChild1Controller.ts b/src/controllers/OrgChild1Controller.ts index 7c1f0634..14f0663b 100644 --- a/src/controllers/OrgChild1Controller.ts +++ b/src/controllers/OrgChild1Controller.ts @@ -105,14 +105,20 @@ export class OrgChild1Controller { } if (requestBody.isOfficer == true) { - await Promise.all( - rootIdExits.orgChild1s - .filter((x: OrgChild1) => x.isOfficer == true) - .map(async (item: OrgChild1) => { - item.isOfficer = false; - await this.child1Repository.save(item); - }), - ); + const orgRevision = await this.orgRevisionRepository.findOne({ + where: { id: rootIdExits.orgRevisionId }, + relations: ["orgChild1s"], + }); + if (orgRevision != null) { + await Promise.all( + orgRevision.orgChild1s + .filter((x: OrgChild1) => x.isOfficer == true) + .map(async (item: OrgChild1) => { + item.isOfficer = false; + await this.child1Repository.save(item); + }), + ); + } } const revisionIdExits = await this.orgRevisionRepository.findOne({ @@ -214,14 +220,20 @@ export class OrgChild1Controller { } if (requestBody.isOfficer == true) { - await Promise.all( - rootIdExits.orgChild1s - .filter((x: OrgChild1) => x.isOfficer == true) - .map(async (item: OrgChild1) => { - item.isOfficer = false; - await this.child1Repository.save(item); - }), - ); + const orgRevision = await this.orgRevisionRepository.findOne({ + where: { id: rootIdExits.orgRevisionId }, + relations: ["orgChild1s"], + }); + if (orgRevision != null) { + await Promise.all( + orgRevision.orgChild1s + .filter((x: OrgChild1) => x.isOfficer == true) + .map(async (item: OrgChild1) => { + item.isOfficer = false; + await this.child1Repository.save(item); + }), + ); + } } const revisionIdExits = await this.orgRevisionRepository.findOne({