Skip to content

Feature brands relation#144

Open
MansillaSantiago wants to merge 18 commits intomainfrom
feature-brands-relation
Open

Feature brands relation#144
MansillaSantiago wants to merge 18 commits intomainfrom
feature-brands-relation

Conversation

@MansillaSantiago
Copy link
Contributor

RESUMEN

#42

photoId está relacionado con la tabla photo
image

brands test fixed
image

Copy link
Contributor

@ghnoob ghnoob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

type: Number,
})
photoId: string;
@OneToOne(() => PhotosEntity) @JoinColumn()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +5 to +12
@IsInt()
@ApiProperty({
example: 123,
description: 'The id of the brand',
type: Number,
})
id: number;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no pasarle id cuando creas


it('should update a brand', () => {
const dto: createBrandDTO = { name: 'Mario', photoId: 'ph id' };
const dto: createBrandDTO = { id: 1, name: 'Mario', photoId: 123 };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cuando haces un update el id se lo pasas en la ruta, no en el dto

Comment on lines 22 to 24
findAll(): Promise<Brand[]> {
return this.brandRepo.find();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

borrar este método porque no se usa

) {}

findOne(id: number) {
findOne(id: number): Promise<Brand> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

falta tirar un 404 cuando no encuentra el brand

}

async update(id: number, body: any) {
async update(id: number, body: any): Promise<Brand> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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[]> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiene que recibir el dto, no un any

@Alonso-Pablo Alonso-Pablo linked an issue Dec 18, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agregar relaciones en la entidad photo

4 participants