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
+3 -2
View File
@@ -24,7 +24,8 @@ export class RunnerController {
@OpenAPI({ description: 'Lists all runners.' })
async getAll() {
let responseRunners: ResponseRunner[] = new Array<ResponseRunner>();
const runners = await this.runnerRepository.find();
const runners = await this.runnerRepository.find({ relations: ['scans', 'group'] });
console.log(runners);
runners.forEach(runner => {
responseRunners.push(new ResponseRunner(runner));
});
@@ -37,7 +38,7 @@ export class RunnerController {
@OnUndefined(RunnerNotFoundError)
@OpenAPI({ description: 'Returns a runner of a specified id (if it exists)' })
async getOne(@Param('id') id: number) {
return new ResponseRunner(await this.runnerRepository.findOne({ id: id }));
return new ResponseRunner(await this.runnerRepository.findOne({ id: id }, { relations: ['scans', 'group'] }));
}
@Post()