insert ingredents
This commit is contained in:
parent
22e2dab830
commit
8af791deb9
6 changed files with 28 additions and 32 deletions
|
@ -70,10 +70,10 @@ app.post("/add-recipe", async (req, res) => {
|
|||
const existingIngredient = existingIngredients.find(ing => ing.name === ingredient.name);
|
||||
if (!existingIngredient) {
|
||||
// create the ingredient if there is no entry
|
||||
const [ingredientId] = await db('ingredients').insert({
|
||||
const [newIngredient] = await db('ingredients').insert({
|
||||
name: ingredient.name
|
||||
}, ['id']);
|
||||
ingredientData.push({ id: ingredientId, quantity: ingredient.quantity, unit: ingredient.unit });
|
||||
ingredientData.push({ id: newIngredient.id, quantity: ingredient.quantity, unit: ingredient.unit });
|
||||
} else {
|
||||
// if the ingredient exists use existing entry
|
||||
ingredientData.push({ id: existingIngredient.id, quantity: ingredient.quantity, unit: ingredient.unit });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue