Versie module 1 van 26-7

This commit is contained in:
2026-07-26 22:18:52 +02:00
commit 26a820b41a
39 changed files with 3663 additions and 0 deletions
+85
View File
@@ -0,0 +1,85 @@
const db = require("../config/database");
class ProductRepository {
getAll() {
return db.prepare(`
SELECT
products.*,
categories.name AS category_name,
categories.icon AS category_icon
FROM products
LEFT JOIN categories
ON categories.id = products.category_id
ORDER BY products.name
`).all();
}
findById(id) {
return db.prepare(`
SELECT *
FROM products
WHERE id = ?
`).get(id);
}
create(data) {
return db.prepare(`
INSERT INTO products
(
name,
category_id,
barcode
)
VALUES (?, ?, ?)
`).run(
data.name,
data.category_id || null,
data.barcode || null
);
}
}
module.exports = new ProductRepository();