Skip to content

Commit

Permalink
Fix product updating
Browse files Browse the repository at this point in the history
Fixes: #68
  • Loading branch information
MrBartusek committed Mar 7, 2024
1 parent 69a8291 commit e82aedc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions apps/api/src/models/products/products.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ export class ProductsService {
id: mongoose.Types.ObjectId,
dto: UpdateProductDto,
): Promise<ProductDocument | null> {
const { image, ...rest } = dto;
const product = await this.productsRepository.findOneByIdAndUpdate(id, rest);
const { image, organization, ...rest } = dto;
const product = await this.productsRepository.findOneByIdAndUpdate(id, {
organization: new Types.ObjectId(organization),
...rest,
});
if (!product) return null;

product.imageKey = await this.imagesService.handleImageDtoAndGetKey(product, image);
Expand Down

0 comments on commit e82aedc

Please sign in to comment.