@@ -16,11 +32,15 @@
{item.description}
|
-
- {item.amount}
+ |
|
-
- {item.per100}
+ |
|
{item.energy}
diff --git a/src/lib/components/Food/FoodTable.svelte b/src/lib/components/Food/FoodTable.svelte
index aa52462..1c5c463 100644
--- a/src/lib/components/Food/FoodTable.svelte
+++ b/src/lib/components/Food/FoodTable.svelte
@@ -1,9 +1,8 @@
@@ -34,9 +33,7 @@
|
- {#if create}
-
- {/if}
+
{#each items as f}
{/each}
diff --git a/src/lib/database/food.ts b/src/lib/database/food.ts
index 2a6c4e4..6c52004 100644
--- a/src/lib/database/food.ts
+++ b/src/lib/database/food.ts
@@ -77,6 +77,19 @@ limit 1
async GetYearly(): Promise<[AggregatedFood[], Err]> {
const rows = await db.select(`select ${aggColumns.join(', ')} from yearly limit 100`)
return [rows, null]
+ },
+ async Update(food: Food): Promise<[Food, Err]> {
+ await db.execute(`
+update food set
+amount = $1,
+per100 = $2
+where rowid = $3
+ `, [food.amount, food.per100, food.rowid])
+ const res = await db.select(`select ${columns.join(', ')} from food where rowid = $1`, [food.rowid])
+ if (!res) return [food, 'no data found']
+ if (res.length == 0) return [food, 'no data found']
+ if (!res[0]) return [food, 'no data found']
+ return [res[0], null]
}
}
diff --git a/src/lib/router/routes/Home.svelte b/src/lib/router/routes/Home.svelte
index cf09ef3..0ef6a05 100644
--- a/src/lib/router/routes/Home.svelte
+++ b/src/lib/router/routes/Home.svelte
@@ -4,5 +4,5 @@
-
+