diff --git a/src/db/client.ts b/src/db/client.ts index 2f56734..b2e689a 100644 --- a/src/db/client.ts +++ b/src/db/client.ts @@ -65,7 +65,7 @@ export const db = { ); const insertId = (result as any).insertId as number; const [rows] = await pool.query( - `select id, manufacturer, model, sku, quantity, description, item_condition as cond, has_box as hasBox, image_path as imagePath, created_at as createdAt + `select id, manufacturer, model, sku, quantity, description, item_condition as cond, has_box as hasBox, image_path as imagePath, (image_data is not null) as hasImage, created_at as createdAt from items where id = ?`, [insertId] ); @@ -78,7 +78,7 @@ export const db = { const where = search ? 'where model like ? or sku like ?' : ''; const params = search ? [`%${search}%`, `%${search}%`] : []; const [rows] = await pool.query( - `select id, manufacturer, model, sku, quantity, description, item_condition as cond, has_box as hasBox, image_path as imagePath, created_at as createdAt + `select id, manufacturer, model, sku, quantity, description, item_condition as cond, has_box as hasBox, image_path as imagePath, (image_data is not null) as hasImage, created_at as createdAt from items ${where} order by id asc`, params ); @@ -89,7 +89,7 @@ export const db = { async getItem(id: number) { await getReady(); const [rows] = await pool.query( - `select id, manufacturer, model, sku, quantity, description, item_condition as cond, has_box as hasBox, image_path as imagePath, created_at as createdAt + `select id, manufacturer, model, sku, quantity, description, item_condition as cond, has_box as hasBox, image_path as imagePath, (image_data is not null) as hasImage, created_at as createdAt from items where id = ?`, [id] ); diff --git a/src/public/index.html b/src/public/index.html index f2486f3..b1cc2a9 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -102,7 +102,7 @@