Vibed it... :(
This commit is contained in:
177
backend/seedData.js
Normal file
177
backend/seedData.js
Normal file
@@ -0,0 +1,177 @@
|
||||
const mongoose = require('mongoose');
|
||||
const Recipe = require('./models/Recipe');
|
||||
require('dotenv').config();
|
||||
|
||||
const sampleRecipes = [
|
||||
{
|
||||
title: "Classic Spaghetti Carbonara",
|
||||
description: "A traditional Italian pasta dish with eggs, cheese, and pancetta",
|
||||
ingredients: [
|
||||
{ name: "spaghetti", amount: 400, unit: "g" },
|
||||
{ name: "pancetta", amount: 150, unit: "g" },
|
||||
{ name: "eggs", amount: 3, unit: "whole" },
|
||||
{ name: "parmesan cheese", amount: 100, unit: "g" },
|
||||
{ name: "black pepper", amount: 1, unit: "tsp" },
|
||||
{ name: "salt", amount: 1, unit: "tsp" }
|
||||
],
|
||||
instructions: [
|
||||
{ step: 1, description: "Cook spaghetti in salted boiling water until al dente" },
|
||||
{ step: 2, description: "Fry pancetta until crispy" },
|
||||
{ step: 3, description: "Beat eggs with grated parmesan and black pepper" },
|
||||
{ step: 4, description: "Drain pasta and mix with pancetta" },
|
||||
{ step: 5, description: "Remove from heat and quickly stir in egg mixture" },
|
||||
{ step: 6, description: "Serve immediately with extra parmesan" }
|
||||
],
|
||||
servings: 4,
|
||||
prepTime: 10,
|
||||
cookTime: 15,
|
||||
category: "dinner",
|
||||
difficulty: "medium",
|
||||
imageUrl: "https://images.unsplash.com/photo-1621996346565-e3dbc353d2e5?w=500"
|
||||
},
|
||||
{
|
||||
title: "Chocolate Chip Cookies",
|
||||
description: "Soft and chewy homemade chocolate chip cookies",
|
||||
ingredients: [
|
||||
{ name: "all-purpose flour", amount: 2.25, unit: "cups" },
|
||||
{ name: "butter", amount: 1, unit: "cup" },
|
||||
{ name: "brown sugar", amount: 0.75, unit: "cup" },
|
||||
{ name: "white sugar", amount: 0.75, unit: "cup" },
|
||||
{ name: "eggs", amount: 2, unit: "whole" },
|
||||
{ name: "vanilla extract", amount: 2, unit: "tsp" },
|
||||
{ name: "baking soda", amount: 1, unit: "tsp" },
|
||||
{ name: "salt", amount: 1, unit: "tsp" },
|
||||
{ name: "chocolate chips", amount: 2, unit: "cups" }
|
||||
],
|
||||
instructions: [
|
||||
{ step: 1, description: "Preheat oven to 375°F (190°C)" },
|
||||
{ step: 2, description: "Cream butter and sugars together" },
|
||||
{ step: 3, description: "Beat in eggs and vanilla" },
|
||||
{ step: 4, description: "Mix in flour, baking soda, and salt" },
|
||||
{ step: 5, description: "Stir in chocolate chips" },
|
||||
{ step: 6, description: "Drop spoonfuls on baking sheet" },
|
||||
{ step: 7, description: "Bake for 9-11 minutes until golden brown" }
|
||||
],
|
||||
servings: 24,
|
||||
prepTime: 15,
|
||||
cookTime: 11,
|
||||
category: "dessert",
|
||||
difficulty: "easy",
|
||||
imageUrl: "https://images.unsplash.com/photo-1499636136210-6f4ee915583e?w=500"
|
||||
},
|
||||
{
|
||||
title: "Caesar Salad",
|
||||
description: "Fresh romaine lettuce with classic Caesar dressing and croutons",
|
||||
ingredients: [
|
||||
{ name: "romaine lettuce", amount: 2, unit: "heads" },
|
||||
{ name: "parmesan cheese", amount: 0.5, unit: "cup" },
|
||||
{ name: "croutons", amount: 1, unit: "cup" },
|
||||
{ name: "mayonnaise", amount: 0.5, unit: "cup" },
|
||||
{ name: "lemon juice", amount: 2, unit: "tbsp" },
|
||||
{ name: "garlic", amount: 2, unit: "cloves" },
|
||||
{ name: "anchovy paste", amount: 1, unit: "tsp" },
|
||||
{ name: "worcestershire sauce", amount: 1, unit: "tsp" },
|
||||
{ name: "black pepper", amount: 0.5, unit: "tsp" }
|
||||
],
|
||||
instructions: [
|
||||
{ step: 1, description: "Wash and chop romaine lettuce" },
|
||||
{ step: 2, description: "Make dressing by mixing mayo, lemon juice, minced garlic, anchovy paste, and worcestershire" },
|
||||
{ step: 3, description: "Toss lettuce with dressing" },
|
||||
{ step: 4, description: "Top with parmesan cheese and croutons" },
|
||||
{ step: 5, description: "Season with black pepper and serve" }
|
||||
],
|
||||
servings: 4,
|
||||
prepTime: 15,
|
||||
cookTime: 0,
|
||||
category: "lunch",
|
||||
difficulty: "easy",
|
||||
imageUrl: "https://images.unsplash.com/photo-1546793665-c74683f339c1?w=500"
|
||||
},
|
||||
{
|
||||
title: "Pancakes",
|
||||
description: "Fluffy breakfast pancakes perfect for weekend mornings",
|
||||
ingredients: [
|
||||
{ name: "all-purpose flour", amount: 1.5, unit: "cups" },
|
||||
{ name: "sugar", amount: 3, unit: "tbsp" },
|
||||
{ name: "baking powder", amount: 1, unit: "tbsp" },
|
||||
{ name: "salt", amount: 0.5, unit: "tsp" },
|
||||
{ name: "milk", amount: 1.25, unit: "cups" },
|
||||
{ name: "egg", amount: 1, unit: "whole" },
|
||||
{ name: "butter", amount: 3, unit: "tbsp" },
|
||||
{ name: "vanilla extract", amount: 1, unit: "tsp" }
|
||||
],
|
||||
instructions: [
|
||||
{ step: 1, description: "Mix dry ingredients in a large bowl" },
|
||||
{ step: 2, description: "Whisk together milk, egg, melted butter, and vanilla" },
|
||||
{ step: 3, description: "Pour wet ingredients into dry ingredients and stir until just combined" },
|
||||
{ step: 4, description: "Heat griddle or large skillet over medium heat" },
|
||||
{ step: 5, description: "Pour 1/4 cup batter for each pancake" },
|
||||
{ step: 6, description: "Cook until bubbles form on surface, then flip" },
|
||||
{ step: 7, description: "Cook until golden brown on both sides" }
|
||||
],
|
||||
servings: 4,
|
||||
prepTime: 10,
|
||||
cookTime: 15,
|
||||
category: "breakfast",
|
||||
difficulty: "easy",
|
||||
imageUrl: "https://images.unsplash.com/photo-1567620905732-2d1ec7ab7445?w=500"
|
||||
},
|
||||
{
|
||||
title: "Beef Stir Fry",
|
||||
description: "Quick and healthy beef stir fry with vegetables",
|
||||
ingredients: [
|
||||
{ name: "beef sirloin", amount: 1, unit: "lb" },
|
||||
{ name: "broccoli", amount: 2, unit: "cups" },
|
||||
{ name: "bell peppers", amount: 2, unit: "whole" },
|
||||
{ name: "carrots", amount: 2, unit: "whole" },
|
||||
{ name: "soy sauce", amount: 3, unit: "tbsp" },
|
||||
{ name: "garlic", amount: 3, unit: "cloves" },
|
||||
{ name: "ginger", amount: 1, unit: "tbsp" },
|
||||
{ name: "vegetable oil", amount: 2, unit: "tbsp" },
|
||||
{ name: "cornstarch", amount: 1, unit: "tbsp" },
|
||||
{ name: "rice", amount: 2, unit: "cups" }
|
||||
],
|
||||
instructions: [
|
||||
{ step: 1, description: "Cut beef into thin strips and marinate with soy sauce and cornstarch" },
|
||||
{ step: 2, description: "Prepare vegetables by cutting into bite-sized pieces" },
|
||||
{ step: 3, description: "Heat oil in wok or large skillet over high heat" },
|
||||
{ step: 4, description: "Stir-fry beef until browned, remove from pan" },
|
||||
{ step: 5, description: "Stir-fry vegetables until crisp-tender" },
|
||||
{ step: 6, description: "Return beef to pan, add garlic and ginger" },
|
||||
{ step: 7, description: "Stir-fry for 2 more minutes and serve over rice" }
|
||||
],
|
||||
servings: 4,
|
||||
prepTime: 20,
|
||||
cookTime: 15,
|
||||
category: "dinner",
|
||||
difficulty: "medium",
|
||||
imageUrl: "https://images.unsplash.com/photo-1603133872878-684f208fb84b?w=500"
|
||||
}
|
||||
];
|
||||
|
||||
async function seedDatabase() {
|
||||
try {
|
||||
// Connect to MongoDB
|
||||
await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/recipe-management');
|
||||
console.log('Connected to MongoDB');
|
||||
|
||||
// Clear existing recipes
|
||||
await Recipe.deleteMany({});
|
||||
console.log('Cleared existing recipes');
|
||||
|
||||
// Insert sample recipes
|
||||
await Recipe.insertMany(sampleRecipes);
|
||||
console.log('Sample recipes inserted successfully');
|
||||
|
||||
console.log(`Inserted ${sampleRecipes.length} recipes`);
|
||||
|
||||
// Close connection
|
||||
await mongoose.connection.close();
|
||||
console.log('Database connection closed');
|
||||
} catch (error) {
|
||||
console.error('Error seeding database:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
seedDatabase();
|
||||
Reference in New Issue
Block a user