v
export class Recipe extends BaseEntity {
@OneToMany(type => RecipeIngredient, recipeIngredient => recipeIngredient.recipe)
recipeIngredients: RecipeIngredient[];
}
export class RecipeIngredient extends BaseEntity {
@OneToOne(type => Ingredient)
ingredient: Ingredient;
@ManyToOne(type => Recipe, recipe => recipe.recipeIngredients)
recipe: Recipe;
}
пытаюсь сохранить это все но не сохраняет
const recipe = new Recipe();
recipe.name = name;
recipe.description = description;
recipe.imgUrl = imgUrl;
const recipeIngredientsID = recipeIngredients.map(item => item.recipe_id);
const ingredients = await Ingredient.findByIds(recipeIngredientsID);
ingredients.forEach(ingredient => {
const recipeIngr = new RecipeIngredient();
recipeIngr.ingredient = ingredient;
recipe.recipeIngredients = recipe.recipeIngredients ? [ ...recipe.recipeIngredients, recipeIngr ] : [ recipeIngr ];
})
await recipe.save();
проблема в том что показывает что возвращает все отлично но на деле recipeIngredients пустой. тоисть как я понимаю не сохраняеться recipe.recipeIngredients
добавлял await recipeIngr.save()
выбивает ошибку
Cannot perform update query because update values are not defined. Call "qb.set(...)" method to specify updated values.