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
+107
View File
@@ -0,0 +1,107 @@
require("dotenv").config();
const db = require("../config/database");
const categories = [
["Groente", "🥬"],
["Fruit", "🍎"],
["Zuivel", "🥛"],
["Brood", "🍞"],
["Dranken", "🥤"],
["Huishouden", "🧻"]
];
const products = [
[
"Melk",
3
],
[
"Bananen",
2
],
[
"Brood",
4
],
[
"Koffie",
5
],
[
"WC papier",
6
]
];
const insertProduct = db.prepare(`
INSERT OR IGNORE INTO products
(
name,
category_id
)
VALUES (?,?)
`);
const seedProducts = db.transaction(() => {
for(const product of products){
insertProduct.run(product);
}
});
seedProducts();
const insert = db.prepare(`
INSERT OR IGNORE INTO categories
(name, icon)
VALUES (?,?)
`);
const seed = db.transaction(() => {
for (const category of categories) {
insert.run(category);
}
});
seed();
console.log("Seed voltooid.");