mirror of
https://github.com/Mueller-Patrick/Betterzon.git
synced 2024-11-22 14:23:57 +00:00
BETTERZON-38: products findAll now returns the actual products from the DB
This commit is contained in:
parent
82b3521f9e
commit
64cb6959cb
|
@ -74,18 +74,23 @@ const products: Products = {
|
|||
|
||||
export const findAll = async (): Promise<Products> => {
|
||||
let conn;
|
||||
let prodRows = [];
|
||||
try {
|
||||
conn = await pool.getConnection();
|
||||
const rows = await conn.query("SELECT * FROM products");
|
||||
console.log(rows); //[ {val: 1}, meta: ... ]
|
||||
const rows = await conn.query("SELECT product_id, name FROM products WHERE product_id = ?", 1);
|
||||
for(let row in rows){
|
||||
if(row !== 'meta'){
|
||||
prodRows.push(rows[row]);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
throw err;
|
||||
} finally {
|
||||
if (conn) return conn.end();
|
||||
if (conn) conn.end();
|
||||
}
|
||||
|
||||
return products;
|
||||
return prodRows;
|
||||
};
|
||||
|
||||
export const find = async (id: number): Promise<Product> => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user