Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature brands relation #144

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

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

})
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

@@ -38,19 +37,19 @@ describe('brandsController', () => {
});

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

@@ -15,20 +15,20 @@ export class BrandsService {
private brandRepo: Repository<Brand>,
) {}

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

const newBrand = this.brandRepo.create(body);
return this.brandRepo.save(newBrand);
}

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

return this.brandRepo.find();
}

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