Part 1 of the relation fix

This commit is contained in:
2020-12-04 21:18:44 +01:00
parent 056413560e
commit c53e94d205
5 changed files with 14 additions and 13 deletions

View File

@@ -27,7 +27,7 @@ export class RunnerOrganisationController {
@ResponseSchema(RunnerOrganisation, { isArray: true })
@OpenAPI({ description: 'Lists all runnerOrganisations.' })
getAll() {
return this.runnerOrganisationRepository.find();
return this.runnerOrganisationRepository.find({ relations: ['address', 'contact', 'teams'] });
}
@Get('/:id')
@@ -36,7 +36,7 @@ export class RunnerOrganisationController {
@OnUndefined(RunnerOrganisationNotFoundError)
@OpenAPI({ description: 'Returns a runnerOrganisation of a specified id (if it exists)' })
getOne(@Param('id') id: number) {
return this.runnerOrganisationRepository.findOne({ id: id });
return this.runnerOrganisationRepository.findOne({ id: id }, { relations: ['address', 'contact', 'teams'] });
}
@Post()
@@ -59,7 +59,7 @@ export class RunnerOrganisationController {
@ResponseSchema(RunnerOrganisationIdsNotMatchingError, { statusCode: 406 })
@OpenAPI({ description: "Update a runnerOrganisation object (id can't be changed)." })
async put(@Param('id') id: number, @EntityFromBody() runnerOrganisation: RunnerOrganisation) {
let oldRunnerOrganisation = await this.runnerOrganisationRepository.findOne({ id: id });
let oldRunnerOrganisation = await this.runnerOrganisationRepository.findOne({ id: id }, { relations: ['address', 'contact', 'teams'] });
if (!oldRunnerOrganisation) {
throw new RunnerOrganisationNotFoundError();
@@ -80,7 +80,7 @@ export class RunnerOrganisationController {
@ResponseSchema(RunnerOrganisationHasTeamsError, { statusCode: 406 })
@OpenAPI({ description: 'Delete a specified runnerOrganisation (if it exists).' })
async remove(@Param('id') id: number, @QueryParam("force") force: boolean) {
let runnerOrganisation = await this.runnerOrganisationRepository.findOne({ id: id });
let runnerOrganisation = await this.runnerOrganisationRepository.findOne({ id: id }, { relations: ['address', 'contact', 'teams'] });
if (!runnerOrganisation) {
throw new RunnerOrganisationNotFoundError();