require("dotenv").config(); const db = require("../config/database"); const categories = [ ["Groente", "๐Ÿฅฌ"], ["Fruit", "๐ŸŽ"], ["Zuivel", "๐Ÿฅ›"], ["Brood", "๐Ÿž"], ["Dranken", "๐Ÿฅค"], ["Huishouden", "๐Ÿงป"] ]; const products = [ ["Melk", "Zuivel"], ["Bananen", "Fruit"], ["Brood", "Brood"], ["Koffie", "Dranken"], ["WC papier", "Huishouden"] ]; const insertCategory = db.prepare(` INSERT OR IGNORE INTO categories (name, icon) VALUES (?, ?) `); const insertProduct = db.prepare(` INSERT OR IGNORE INTO products (name, category_id) VALUES (?, ?) `); db.transaction(() => { for (const category of categories) { insertCategory.run(category); } for (const [name, categoryName] of products) { const category = db.prepare( "SELECT id FROM categories WHERE name = ?" ).get(categoryName); insertProduct.run(name, category.id); } })(); console.log("Seed voltooid.");