diff --git a/src/modules/foods/providers/food.service.ts b/src/modules/foods/providers/food.service.ts index 46ba3fe..4891fc9 100644 --- a/src/modules/foods/providers/food.service.ts +++ b/src/modules/foods/providers/food.service.ts @@ -88,6 +88,9 @@ export class FoodService { // attach new categories if provided (adds, does not attempt to preserve/remove existing ones) if (Array.isArray(categoryIds) && categoryIds.length) { const categories = await this.categoryRepository.find({ id: { $in: categoryIds } }); + + food.categories.removeAll(); + categories.forEach(cat => { // Collection.add will ignore duplicates food.categories.add(cat);