marca y modelo arreglado
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||
// import { Carrito } from '../../carrito/entity/carrito.entity';
|
||||
// import { Equipo } from '../../equipo/entity/equipo.entity';
|
||||
import { Carrito } from '../../carrito/entity/carrito.entity';
|
||||
import { Equipo } from '../../equipo/entity/equipo.entity';
|
||||
|
||||
@Entity()
|
||||
export class Modelo {
|
||||
@@ -13,9 +13,9 @@ export class Modelo {
|
||||
@Column({ type: String, nullable: false, length: 1 })
|
||||
tipo: string;
|
||||
|
||||
// @OneToMany(() => Carrito, (carrito) => carrito.modelo)
|
||||
// carritos: Carrito[];
|
||||
@OneToMany(() => Carrito, (carrito) => carrito.modelo)
|
||||
carritos: Carrito[];
|
||||
|
||||
// @OneToMany(() => Equipo, (equipo) => equipo.modelo)
|
||||
// equipos: Equipo[];
|
||||
@OneToMany(() => Equipo, (equipo) => equipo.modelo)
|
||||
equipos: Equipo[];
|
||||
}
|
||||
|
||||
@@ -24,6 +24,13 @@ export class ModeloService {
|
||||
return this.repository.find({ where: { tipo }, order: { tipo: 'ASC' } });
|
||||
}
|
||||
|
||||
findById(id_modelo: number, tipo: string, validarExistencia = true) {
|
||||
return this.repository.findOne({ id_modelo, tipo }).then((modelo) => {
|
||||
if (validarExistencia && !modelo)
|
||||
throw new ConflictException('No existe este modelo.');
|
||||
return modelo;
|
||||
});
|
||||
}
|
||||
findByModelo(modelo: string, tipo: string, validarExistencia = true) {
|
||||
return this.repository.findOne({ modelo, tipo }).then((modelo) => {
|
||||
if (validarExistencia && !modelo)
|
||||
|
||||
Reference in New Issue
Block a user