Legt de bestaande wijzigingen in de hoofdworktree vast voordat de laatste worktree wordt gemerged.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
98 lines
1.2 KiB
JavaScript
98 lines
1.2 KiB
JavaScript
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 insertCategory = db.prepare(`
|
|
|
|
INSERT INTO categories (name, icon)
|
|
SELECT ?, ?
|
|
WHERE NOT EXISTS (SELECT 1 FROM categories WHERE name = ?)
|
|
|
|
`);
|
|
|
|
const seedCategories = db.transaction(() => {
|
|
|
|
for (const category of categories) {
|
|
insertCategory.run(category[0], category[1], category[0]);
|
|
}
|
|
|
|
});
|
|
|
|
seedCategories();
|
|
|
|
const insertProduct = db.prepare(`
|
|
|
|
INSERT INTO products (name, category_id)
|
|
SELECT ?, ?
|
|
WHERE NOT EXISTS (SELECT 1 FROM products WHERE name = ?)
|
|
|
|
`);
|
|
|
|
|
|
|
|
|
|
const seedProducts = db.transaction(() => {
|
|
|
|
|
|
for(const product of products){
|
|
|
|
insertProduct.run(product[0], product[1], product[0]);
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
seedProducts();
|
|
|
|
|
|
console.log("Seed voltooid.");
|