added delete function to product table

This commit is contained in:
2026-05-29 23:04:41 +02:00
parent 6bacd1c605
commit 9cab32ddea
6 changed files with 97 additions and 8 deletions
@@ -90,6 +90,7 @@ export const allProducts = async () => {
p.updated_at
FROM products p
JOIN storage_locations s ON p.storage_location = s.uuid
WHERE p.deleted = 0
`);
if (result.length > 0) {
@@ -137,3 +138,16 @@ export const updateItem = async (itemUUID, newValues) => {
return { code: "ep005" }; // error
}
};
export const deleteProduct = async (uuid) => {
const [result] = await pool.query(
`UPDATE products SET deleted = 1 WHERE uuid = UUID_TO_BIN(?);`,
[uuid],
);
if (result.affectedRows > 0) {
return { code: "sp006" }; // success
} else {
return { code: "ep006" }; // error
}
};