update food
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user