Skip to content

Commit 3b23752

Browse files
committed
init and seed sqlite db
1 parent ab112e4 commit 3b23752

File tree

4 files changed

+433
-6
lines changed

4 files changed

+433
-6
lines changed

initdb.js

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
const sql = require('better-sqlite3');
2+
const db = sql('meals.db');
3+
4+
const dummyMeals = [
5+
{
6+
title: 'Juicy Cheese Burger',
7+
slug: 'juicy-cheese-burger',
8+
image: '/images/burger.jpg',
9+
summary:
10+
'A mouth-watering burger with a juicy beef patty and melted cheese, served in a soft bun.',
11+
instructions: `
12+
1. Prepare the patty:
13+
Mix 200g of ground beef with salt and pepper. Form into a patty.
14+
15+
2. Cook the patty:
16+
Heat a pan with a bit of oil. Cook the patty for 2-3 minutes each side, until browned.
17+
18+
3. Assemble the burger:
19+
Toast the burger bun halves. Place lettuce and tomato on the bottom half. Add the cooked patty and top with a slice of cheese.
20+
21+
4. Serve:
22+
Complete the assembly with the top bun and serve hot.
23+
`,
24+
creator: 'John Doe',
25+
creator_email: '[email protected]',
26+
},
27+
{
28+
title: 'Spicy Curry',
29+
slug: 'spicy-curry',
30+
image: '/images/curry.jpg',
31+
summary:
32+
'A rich and spicy curry, infused with exotic spices and creamy coconut milk.',
33+
instructions: `
34+
1. Chop vegetables:
35+
Cut your choice of vegetables into bite-sized pieces.
36+
37+
2. Sauté vegetables:
38+
In a pan with oil, sauté the vegetables until they start to soften.
39+
40+
3. Add curry paste:
41+
Stir in 2 tablespoons of curry paste and cook for another minute.
42+
43+
4. Simmer with coconut milk:
44+
Pour in 500ml of coconut milk and bring to a simmer. Let it cook for about 15 minutes.
45+
46+
5. Serve:
47+
Enjoy this creamy curry with rice or bread.
48+
`,
49+
creator: 'Max Schwarz',
50+
creator_email: '[email protected]',
51+
},
52+
{
53+
title: 'Homemade Dumplings',
54+
slug: 'homemade-dumplings',
55+
image: '/images/dumplings.jpg',
56+
summary:
57+
'Tender dumplings filled with savory meat and vegetables, steamed to perfection.',
58+
instructions: `
59+
1. Prepare the filling:
60+
Mix minced meat, shredded vegetables, and spices.
61+
62+
2. Fill the dumplings:
63+
Place a spoonful of filling in the center of each dumpling wrapper. Wet the edges and fold to seal.
64+
65+
3. Steam the dumplings:
66+
Arrange dumplings in a steamer. Steam for about 10 minutes.
67+
68+
4. Serve:
69+
Enjoy these dumplings hot, with a dipping sauce of your choice.
70+
`,
71+
creator: 'Emily Chen',
72+
creator_email: '[email protected]',
73+
},
74+
{
75+
title: 'Classic Mac n Cheese',
76+
slug: 'classic-mac-n-cheese',
77+
image: '/images/macncheese.jpg',
78+
summary:
79+
"Creamy and cheesy macaroni, a comforting classic that's always a crowd-pleaser.",
80+
instructions: `
81+
1. Cook the macaroni:
82+
Boil macaroni according to package instructions until al dente.
83+
84+
2. Prepare cheese sauce:
85+
In a saucepan, melt butter, add flour, and gradually whisk in milk until thickened. Stir in grated cheese until melted.
86+
87+
3. Combine:
88+
Mix the cheese sauce with the drained macaroni.
89+
90+
4. Bake:
91+
Transfer to a baking dish, top with breadcrumbs, and bake until golden.
92+
93+
5. Serve:
94+
Serve hot, garnished with parsley if desired.
95+
`,
96+
creator: 'Laura Smith',
97+
creator_email: '[email protected]',
98+
},
99+
{
100+
title: 'Authentic Pizza',
101+
slug: 'authentic-pizza',
102+
image: '/images/pizza.jpg',
103+
summary:
104+
'Hand-tossed pizza with a tangy tomato sauce, fresh toppings, and melted cheese.',
105+
instructions: `
106+
1. Prepare the dough:
107+
Knead pizza dough and let it rise until doubled in size.
108+
109+
2. Shape and add toppings:
110+
Roll out the dough, spread tomato sauce, and add your favorite toppings and cheese.
111+
112+
3. Bake the pizza:
113+
Bake in a preheated oven at 220°C for about 15-20 minutes.
114+
115+
4. Serve:
116+
Slice hot and enjoy with a sprinkle of basil leaves.
117+
`,
118+
creator: 'Mario Rossi',
119+
creator_email: '[email protected]',
120+
},
121+
{
122+
title: 'Wiener Schnitzel',
123+
slug: 'wiener-schnitzel',
124+
image: '/images/schnitzel.jpg',
125+
summary:
126+
'Crispy, golden-brown breaded veal cutlet, a classic Austrian dish.',
127+
instructions: `
128+
1. Prepare the veal:
129+
Pound veal cutlets to an even thickness.
130+
131+
2. Bread the veal:
132+
Coat each cutlet in flour, dip in beaten eggs, and then in breadcrumbs.
133+
134+
3. Fry the schnitzel:
135+
Heat oil in a pan and fry each schnitzel until golden brown on both sides.
136+
137+
4. Serve:
138+
Serve hot with a slice of lemon and a side of potato salad or greens.
139+
`,
140+
creator: 'Franz Huber',
141+
creator_email: '[email protected]',
142+
},
143+
{
144+
title: 'Fresh Tomato Salad',
145+
slug: 'fresh-tomato-salad',
146+
image: '/images/tomato-salad.jpg',
147+
summary:
148+
'A light and refreshing salad with ripe tomatoes, fresh basil, and a tangy vinaigrette.',
149+
instructions: `
150+
1. Prepare the tomatoes:
151+
Slice fresh tomatoes and arrange them on a plate.
152+
153+
2. Add herbs and seasoning:
154+
Sprinkle chopped basil, salt, and pepper over the tomatoes.
155+
156+
3. Dress the salad:
157+
Drizzle with olive oil and balsamic vinegar.
158+
159+
4. Serve:
160+
Enjoy this simple, flavorful salad as a side dish or light meal.
161+
`,
162+
creator: 'Sophia Green',
163+
creator_email: '[email protected]',
164+
},
165+
];
166+
167+
db.prepare(`
168+
CREATE TABLE IF NOT EXISTS meals (
169+
id INTEGER PRIMARY KEY AUTOINCREMENT,
170+
slug TEXT NOT NULL UNIQUE,
171+
title TEXT NOT NULL,
172+
image TEXT NOT NULL,
173+
summary TEXT NOT NULL,
174+
instructions TEXT NOT NULL,
175+
creator TEXT NOT NULL,
176+
creator_email TEXT NOT NULL
177+
)
178+
`).run();
179+
180+
async function initData() {
181+
const stmt = db.prepare(`
182+
INSERT INTO meals VALUES (
183+
null,
184+
@slug,
185+
@title,
186+
@image,
187+
@summary,
188+
@instructions,
189+
@creator,
190+
@creator_email
191+
)
192+
`);
193+
194+
for (const meal of dummyMeals) {
195+
stmt.run(meal);
196+
}
197+
}
198+
199+
initData();

meals.db

24 KB
Binary file not shown.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12+
"better-sqlite3": "^9.5.0",
13+
"next": "14.0.3",
1214
"react": "^18",
13-
"react-dom": "^18",
14-
"next": "14.0.3"
15+
"react-dom": "^18"
1516
},
1617
"devDependencies": {
1718
"eslint": "^8",

0 commit comments

Comments
 (0)