23 lines
604 B
TypeScript
23 lines
604 B
TypeScript
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
import { Repository } from 'typeorm';
|
|
import { Status } from './entity/status.entity';
|
|
|
|
@Injectable()
|
|
export class StatusService {
|
|
constructor(
|
|
@InjectRepository(Status) private repository: Repository<Status>,
|
|
) {}
|
|
|
|
findAll() {
|
|
return this.repository.find();
|
|
}
|
|
|
|
findById(id_status: number) {
|
|
return this.repository.findOne({ id_status }).then((status) => {
|
|
if (!status) throw new NotFoundException('No existe este status.');
|
|
return status;
|
|
});
|
|
}
|
|
}
|