From 0be2aa31477f27158532f36bb9e398d145611a75 Mon Sep 17 00:00:00 2001 From: June Date: Fri, 22 Aug 2025 16:19:46 +1200 Subject: [PATCH] basic recipe creation works! --- src/script/newRecipe.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/script/newRecipe.ts b/src/script/newRecipe.ts index 0016b72..5b30a37 100644 --- a/src/script/newRecipe.ts +++ b/src/script/newRecipe.ts @@ -81,17 +81,25 @@ async function addRecipe() { console.log(comps.ings) const ingredientIDs = await Promise.all( - comps.ings.map(async it => (await client.pb.collection('ingredients').create({ - 'quantity': it.quantity, - 'name': it.name, - 'unit': it.name - })).id) // get the id of the returned record + comps.ings.map(async it => (await client.pb.collection('ingredients').create(it)).id) // get the id of the returned record ) - const stepIds = await Promise.all( - + const stepIDs = await Promise.all( + comps.stepList.map(async it => (await client.pb.collection('steps').create(it)).id) ) + const recipe = await client.pb.collection('recipes').create({ + name: comps.name, + description: comps.description, + servings: comps.servings, + worktime: comps.worktime, + waittime: comps.waittime, + rating: comps.rating, + ingredients: ingredientIDs, + steps: stepIDs + }) + + console.log(recipe) } function addIngredient() {