fixed little tings
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { EquipoService } from './equipo.service';
|
||||
import { Equipo } from './entities/equipo.entity';
|
||||
|
||||
@Controller('equipo')
|
||||
export class EquipoController {
|
||||
@@ -11,7 +12,7 @@ export class EquipoController {
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: number) {
|
||||
findOne(@Param('id') id: number):Promise<Equipo> {
|
||||
return this.equipoService.findOne(+id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Equipo } from './entities/equipo.entity';
|
||||
@@ -12,8 +12,12 @@ private readonly equipoRepository: Repository<Equipo>){}
|
||||
return this.equipoRepository.find();
|
||||
}
|
||||
|
||||
findOne(id_equipo: number) {
|
||||
return this.equipoRepository.findOne({where:{id_equipo}});
|
||||
async findOne(id_equipo: number):Promise<Equipo> {
|
||||
const equipo = await this.equipoRepository.findOne({where:{id_equipo}})
|
||||
if(!equipo){
|
||||
throw new NotFoundException("not found");
|
||||
}
|
||||
return equipo;
|
||||
}
|
||||
}
|
||||
//IO
|
||||
Reference in New Issue
Block a user