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

@@ -25,7 +25,7 @@ export class RunnerTeamController {
@ResponseSchema(RunnerTeam, { isArray: true })
@OpenAPI({ description: 'Lists all runnerTeams.' })
getAll() {
return this.runnerTeamRepository.find();
return this.runnerTeamRepository.find({ relations: ['parentGroup', 'contact'] });
}
@Get('/:id')
@@ -34,7 +34,7 @@ export class RunnerTeamController {
@OnUndefined(RunnerTeamNotFoundError)
@OpenAPI({ description: 'Returns a runnerTeam of a specified id (if it exists)' })
getOne(@Param('id') id: number) {
return this.runnerTeamRepository.findOne({ id: id });
return this.runnerTeamRepository.findOne({ id: id }, { relations: ['parentGroup', 'contact'] });
}
@Post()
@@ -57,7 +57,7 @@ export class RunnerTeamController {
@ResponseSchema(RunnerTeamIdsNotMatchingError, { statusCode: 406 })
@OpenAPI({ description: "Update a runnerTeam object (id can't be changed)." })
async put(@Param('id') id: number, @EntityFromBody() runnerTeam: RunnerTeam) {
let oldRunnerTeam = await this.runnerTeamRepository.findOne({ id: id });
let oldRunnerTeam = await this.runnerTeamRepository.findOne({ id: id }, { relations: ['parentGroup', 'contact'] });
if (!oldRunnerTeam) {
throw new RunnerTeamNotFoundError();
@@ -77,7 +77,7 @@ export class RunnerTeamController {
@ResponseSchema(RunnerTeamHasRunnersError, { statusCode: 406 })
@OpenAPI({ description: 'Delete a specified runnerTeam (if it exists).' })
async remove(@Param('id') id: number, @QueryParam("force") force: boolean) {
let runnerTeam = await this.runnerTeamRepository.findOne({ id: id });
let runnerTeam = await this.runnerTeamRepository.findOne({ id: id }, { relations: ['parentGroup', 'contact'] });
if (!runnerTeam) {
throw new RunnerTeamNotFoundError();