Fix not inserting per100s
This commit is contained in:
@@ -28,8 +28,10 @@
|
||||
if (event.key == 'Enter') {
|
||||
event.preventDefault()
|
||||
item.food = name
|
||||
item.amount = parseInt(amount)
|
||||
item.description = description
|
||||
item.amount = parseInt(amount)
|
||||
item.per100 = parseInt(per100)
|
||||
|
||||
const [dbFood, err]: [Food, Err] = await FoodService.Create(item)
|
||||
name = ''
|
||||
amount = ''
|
||||
|
@@ -42,7 +42,11 @@ order by date DESC;
|
||||
if (!food.food) return [food, 'food.food is required']
|
||||
if (!food.amount) throw [food, 'food.amount is required']
|
||||
|
||||
const res = await db.execute(`insert into food (food, description, amount) values ($1, $2, $3)`, [food.food, food.description, food.amount])
|
||||
let res
|
||||
if (!!food.per100)
|
||||
res = await db.execute(`insert into food (food, description, amount, per100) values ($1, $2, $3, $4)`, [food.food, food.description, food.amount, food.per100])
|
||||
else
|
||||
res = await db.execute(`insert into food (food, description, amount) values ($1, $2, $3)`, [food.food, food.description, food.amount])
|
||||
const rows = await db.select<Food[]>(`select ${columns.join(', ')} from foodView where rowid = $1`, [res.lastInsertId])
|
||||
|
||||
if (!rows) return [food, 'no data found']
|
||||
|
Reference in New Issue
Block a user