Untitled
Anonymous
plain_text
01/23/2024 3:39 PM
988 B
18
Indexable
const insertNewSale = async (timeAdded) => {
const [createdSale] = await connection.execute(
'INSERT INTO sales (date) VALUES (?)',
[timeAdded],
);
return createdSale;
};
const insertProductIntoSale = async (nextID, createdSale) => {
if (createdSale) {
const SQLquery = createdSale.map((sale) => {
const { productId, quantity } = sale;
return connection.execute(
`INSERT INTO sales_products (sale_id, product_id, quantity)
VALUES (?, ?, ?)`,
[nextID, productId, quantity],
);
});
const addedSale = await Promise.all(SQLquery);
return addedSale;
}
};
// ESSAS SAO AS EXPORTAÇÕES KRLLLLLLLLLLLLLLLLLLLLL
findSaleById,
insertNewSale,
insertProductIntoSale,Editor is loading...
Leave a Comment