Conversation
ghnoob
left a comment
There was a problem hiding this comment.
Antes de hacer más cambios mergea main en esta rama, borra el .env y el ormconfig.json.
El app.module tampoco lo tendrias que tocar porque no estas agregando ningun modulo
src/brands/entities/brands.entity.ts
Outdated
| type: Number, | ||
| }) | ||
| photoId: string; | ||
| @OneToOne(() => PhotosEntity) @JoinColumn() |
There was a problem hiding this comment.
la relacion está mal hecha. estábamos usando relaciones polimórifcas y no one to one.
igualmente en una relación one to one tendrias que cambiar @JoinColumn() por @JoinColumn({ name: 'photo_id' }) photoId: Number por photo: PhotosEntity
| @IsInt() | ||
| @ApiProperty({ | ||
| example: 123, | ||
| description: 'The id of the brand', | ||
| type: Number, | ||
| }) | ||
| id: number; | ||
|
|
There was a problem hiding this comment.
no se le tiene que pasar un id cuando creas
|
|
||
| it('should create a brand', () => { | ||
| expect(controller.create({ name: 'Mario', photoId: 'ph id' })).toEqual({ | ||
| expect(controller.create({ id:1, name: 'Mario', photoId: 123 })).toEqual({ |
|
|
||
| it('should update a brand', () => { | ||
| const dto: createBrandDTO = { name: 'Mario', photoId: 'ph id' }; | ||
| const dto: createBrandDTO = { id: 1, name: 'Mario', photoId: 123 }; |
There was a problem hiding this comment.
cuando haces un update el id se lo pasas en la ruta, no en el dto
| findAll(): Promise<Brand[]> { | ||
| return this.brandRepo.find(); | ||
| } |
There was a problem hiding this comment.
borrar este método porque no se usa
| ) {} | ||
|
|
||
| findOne(id: number) { | ||
| findOne(id: number): Promise<Brand> { |
There was a problem hiding this comment.
falta tirar un 404 cuando no encuentra el brand
| } | ||
|
|
||
| async update(id: number, body: any) { | ||
| async update(id: number, body: any): Promise<Brand> { |
There was a problem hiding this comment.
falta tirar un 404 cuando no encuenta el id
lo mismo para delete
ademas aca tiene que recibir el dto, no un any
| } | ||
|
|
||
| create(body: any) { | ||
| create(body: any): Promise<Brand[]> { |
There was a problem hiding this comment.
tiene que recibir el dto, no un any
RESUMEN
#42
photoId está relacionado con la tabla photo

brands test fixed
