23 lines
637 B
TypeScript
23 lines
637 B
TypeScript
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
import { Repository } from 'typeorm';
|
|
import { Equipo } from './entities/equipo.entity';
|
|
|
|
@Injectable()
|
|
export class EquipoService {
|
|
constructor(@InjectRepository(Equipo)
|
|
private readonly equipoRepository: Repository<Equipo>){}
|
|
|
|
findAll() {
|
|
return this.equipoRepository.find();
|
|
}
|
|
|
|
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
|