Fix for getting one

ref #13
This commit is contained in:
2020-12-09 18:11:23 +01:00
parent e4cb8eba1d
commit 204e2352a9
4 changed files with 12 additions and 4 deletions

View File

@@ -41,7 +41,9 @@ export class RunnerOrganisationController {
@OnUndefined(RunnerOrganisationNotFoundError)
@OpenAPI({ description: 'Returns a runnerOrganisation of a specified id (if it exists)' })
async getOne(@Param('id') id: number) {
return new ResponseRunnerOrganisation(await this.runnerOrganisationRepository.findOne({ id: id }, { relations: ['address', 'contact', 'teams'] }));
let runnerOrg = await this.runnerOrganisationRepository.findOne({ id: id }, { relations: ['address', 'contact', 'teams'] });
if (!runnerOrg) { throw new RunnerOrganisationNotFoundError(); }
return new ResponseRunnerOrganisation(runnerOrg);
}
@Post()