This commit is contained in:
lemuel 2022-04-12 14:14:33 -05:00
parent e4c9bf2622
commit 03a886237f
2 changed files with 11 additions and 3 deletions

View File

@ -7,6 +7,6 @@ export class InstitucionController {
@Get() @Get()
get() { get() {
return this.institucionService.findAllInstitucion(); return this.institucionService.findAll();
} }
} }

View File

@ -1,4 +1,4 @@
import { Injectable } from '@nestjs/common'; import { Injectable, NotFoundException } from '@nestjs/common';
import { Repository } from 'typeorm'; import { Repository } from 'typeorm';
import { InjectRepository } from '@nestjs/typeorm'; import { InjectRepository } from '@nestjs/typeorm';
import { Institucion } from './institucion.entity'; import { Institucion } from './institucion.entity';
@ -9,7 +9,15 @@ export class InstitucionService {
@InjectRepository(Institucion) private repository: Repository<Institucion>, @InjectRepository(Institucion) private repository: Repository<Institucion>,
) {} ) {}
findAllInstitucion() { findAll() {
return this.repository.find(); return this.repository.find();
} }
findById(id_institucion: number) {
const institucion = this.repository.find({ where: { id_institucion } });
if (!institucion)
throw new NotFoundException('No existe esta institución.');
return institucion;
}
} }