Fix bug with creating meal list

This commit is contained in:
= 2021-01-16 22:52:40 +01:00
parent a96c1d9c07
commit 9a4f1038ff

View File

@ -4,7 +4,8 @@ const ApiError = require('../utils/ApiError');
const createMeal = async (mealBody) => { const createMeal = async (mealBody) => {
const meal = await Meal.create(mealBody); const meal = await Meal.create(mealBody);
return meal; const mealWithProducts = await meal.populate('products.product').execPopulate();
return mealWithProducts;
}; };
const queryMeals = async (filter, options) => { const queryMeals = async (filter, options) => {
@ -38,7 +39,8 @@ const updateMealById = async (mealId, updateBody) => {
} }
Object.assign(meal, updateBody); Object.assign(meal, updateBody);
await meal.save(); await meal.save();
return meal; const mealWithProducts = await meal.populate('products.product').execPopulate();
return mealWithProducts;
}; };
const updateMealProductsById = async (mealId, updateBody) => { const updateMealProductsById = async (mealId, updateBody) => {