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 Marca {
|
||||
@@ -13,9 +13,9 @@ export class Marca {
|
||||
@Column({ type: String, nullable: false, length: 1 })
|
||||
tipo: string;
|
||||
|
||||
// @OneToMany(() => Carrito, (carrito) => carrito.marca)
|
||||
// carritos: Carrito[];
|
||||
@OneToMany(() => Carrito, (carrito) => carrito.marca)
|
||||
carritos: Carrito[];
|
||||
|
||||
// @OneToMany(() => Equipo, (equipo) => equipo.marca)
|
||||
// equipos: Equipo[];
|
||||
@OneToMany(() => Equipo, (equipo) => equipo.marca)
|
||||
equipos: Equipo[];
|
||||
}
|
||||
|
||||
@@ -22,6 +22,14 @@ export class MarcaService {
|
||||
return this.repository.find({ where: { tipo }, order: { tipo: 'ASC' } });
|
||||
}
|
||||
|
||||
findById(id_marca: number, tipo: string, validarExistencia = true) {
|
||||
return this.repository.findOne({ id_marca, tipo }).then((marca) => {
|
||||
if (validarExistencia && !marca)
|
||||
throw new ConflictException('No existe esta marca.');
|
||||
return marca;
|
||||
});
|
||||
}
|
||||
|
||||
findByMarca(marca: string, tipo: string, validarExistencia = true) {
|
||||
return this.repository.findOne({ marca, tipo }).then((marca) => {
|
||||
if (validarExistencia && !marca)
|
||||
|
||||
Reference in New Issue
Block a user