Spaces:
Running
Running
File size: 9,249 Bytes
1e480b5 3236712 1e480b5 3236712 1e480b5 3236712 1e480b5 3236712 1e480b5 3236712 1e480b5 3236712 1e480b5 3236712 1e480b5 3236712 1e480b5 3236712 1e480b5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | /**
* Menu seed β seeds all dishes, variants, and deals from the Golden Wok menu card.
* Run: npm run seed:menu
*/
require('dotenv').config({ path: require('path').resolve(__dirname, '../.env') });
const mongoose = require('mongoose');
const Category = require('./models/Category');
const MenuItem = require('./models/MenuItem');
// ββ Full menu data from menu card ββββββββββββββββββββββββββββ
const MENU_DATA = [
// ββ SOUPS ββββββββββββββββββββββββββββββββββββββββββββββββββ
{
category: 'Soups',
items: [
{ name: 'Chicken Corn Soup', variants: [{ label: 'Full', price: 800 }, { label: 'Half', price: 500 }] },
{ name: 'Chicken Hot and Sour Soup', variants: [{ label: 'Full', price: 800 }, { label: 'Half', price: 500 }] },
{ name: 'Soup Single Cup', variants: [{ label: 'Regular', price: 270 }] },
{ name: 'Fish Crackers', variants: [{ label: 'Full', price: 400 }, { label: 'Half', price: 280 }] },
],
},
// ββ APPETIZERS βββββββββββββββββββββββββββββββββββββββββββββ
{
category: 'Appetizers',
items: [
{ name: 'Honey Chicken Wings', variants: [{ label: 'Full', price: 800 }, { label: 'Half', price: 600 }] },
{ name: 'Spicy Fried Fish', variants: [{ label: 'Full', price: 1600 }, { label: 'Half', price: 900 }] },
{ name: 'Chicken Drum Stick', variants: [{ label: 'Full', price: 1700 }, { label: 'Half', price: 900 }] },
],
},
// ββ RICE βββββββββββββββββββββββββββββββββββββββββββββββββββ
{
category: 'Rice',
items: [
{ name: 'Chicken Fried Rice', variants: [{ label: 'Full', price: 800 }, { label: 'Half', price: 550 }] },
{ name: 'Egg Fried Rice', variants: [{ label: 'Full', price: 750 }, { label: 'Half', price: 500 }] },
{ name: 'Chicken Masala Rice', variants: [{ label: 'Full', price: 800 }, { label: 'Half', price: 550 }] },
],
},
// ββ NOODLES ββββββββββββββββββββββββββββββββββββββββββββββββ
{
category: 'Noodles',
items: [
{ name: 'Chicken Chow Mein', variants: [{ label: 'Full', price: 900 }, { label: 'Half', price: 600 }] },
// Prawn Chow Mein listed as N/A β created but marked unavailable
{ name: 'Prawn Chow Mein', variants: [{ label: 'Full', price: 0 }, { label: 'Half', price: 0 }], available: false },
],
},
// ββ CHICKEN GRAVY ββββββββββββββββββββββββββββββββββββββββββ
{
category: 'Chicken Gravy',
items: [
{ name: 'Chicken Manchurian', variants: [{ label: 'Full', price: 900 }, { label: 'Half', price: 600 }] },
{ name: 'Black Pepper Chicken with Chillies & Onion', variants: [{ label: 'Full', price: 900 }, { label: 'Half', price: 600 }] },
{ name: 'Braised Chicken in Hot Spices', variants: [{ label: 'Full', price: 1050 }, { label: 'Half', price: 700 }] },
{ name: 'Garlic Chicken', variants: [{ label: 'Full', price: 1000 }, { label: 'Half', price: 700 }] },
{ name: 'Chicken Button Mushroom in Garlic Sauce', variants: [{ label: 'Full', price: 1000 }, { label: 'Half', price: 700 }] },
{ name: 'Chicken Chilly Dry', variants: [{ label: 'Full', price: 1050 }, { label: 'Half', price: 850 }] },
{ name: 'Chicken Chilly Vegetable', variants: [{ label: 'Full', price: 1000 }, { label: 'Half', price: 700 }] },
{ name: 'Chicken with Cashew Nuts', variants: [{ label: 'Full', price: 1050 }] },
{ name: 'Chicken Shashlik', variants: [{ label: 'Full', price: 1000 }, { label: 'Half', price: 700 }] },
],
},
// ββ SEA FOOD βββββββββββββββββββββββββββββββββββββββββββββββ
{
category: 'Sea Food',
items: [
{ name: 'Garlic Shrimp', variants: [{ label: 'Full', price: 1600 }] },
{ name: 'Hot and Sour Shrimp', variants: [{ label: 'Full', price: 1500 }] },
{ name: 'Garlic Fish', variants: [{ label: 'Full', price: 1600 }] },
{ name: 'Braised Fish in Hot Spices', variants: [{ label: 'Full', price: 1600 }] },
],
},
// ββ BEVERAGES ββββββββββββββββββββββββββββββββββββββββββββββ
{
category: 'Beverages',
items: [
{ name: 'Coca Cola', variants: [{ label: '250 ml', price: 70 }, { label: 'Half Litre', price: 120 }, { label: '1.5 Litre', price: 180 }] },
{ name: 'Mineral Water', variants: [{ label: 'Half Litre', price: 60 }, { label: '1.5 Litre', price: 100 }] },
],
},
// ββ DEALS ββββββββββββββββββββββββββββββββββββββββββββββββββ
{
category: 'Deals',
items: [
{ name: 'Deal 1 β Chicken Manchurian with Rice (Single Person)', variants: [{ label: 'Single Person', price: 600 }] },
{ name: 'Deal 2 β Chicken Chow Mein with Black Pepper Chicken (Single Person)', variants: [{ label: 'Single Person', price: 600 }] },
{ name: 'Deal 3 β Hot & Sour Soup with One Piece Drum Stick', variants: [{ label: 'Regular', price: 550 }] },
{ name: 'Deal 4 β Chicken Manchurian with Rice (Full)', variants: [{ label: 'Full', price: 1400 }] },
{ name: 'Deal 5 β Chicken Chow Mein with Black Pepper Chicken (Full)', variants: [{ label: 'Full', price: 1400 }] },
{ name: 'Deal 6 β Masala Fried Rice + Chicken Chilly Dry + 2 Fried Wings', variants: [{ label: 'Regular', price: 900 }] },
{ name: 'Deal 7 β Egg Fried Rice + Braised Chicken in Hot Spices + Two Fried Wings', variants: [{ label: 'Regular', price: 900 }] },
{ name: 'Deal 8 β Chicken Chow Mein + Masala Fried Rice + Chicken Shashlik', variants: [{ label: 'Regular', price: 1700 }] },
{ name: 'Deal 9 β Fried Rice + Chicken Chow Mein + Black Pepper Chicken', variants: [{ label: 'Regular', price: 900 }] },
{ name: 'Deal 10 β Full Masala Fried Rice + Garlic Fish / Fish Chilly and Ginger', variants: [{ label: 'Regular', price: 1600 }] },
{ name: 'Deal 11 β Hot & Spicy Fried Wings (10 Pieces)', variants: [{ label: '10 Pieces', price: 700 }] },
{ name: 'Deal 12 β Β½ Egg Fried Rice + Β½ Chicken Chilly Dry', variants: [{ label: 'Regular', price: 1100 }] },
{ name: 'Deal 13 β Chicken Masala Rice + Garlic Chicken + 4 Pieces Wings', variants: [{ label: 'Regular', price: 1300 }] },
{ name: 'Deal 14 β Full Hot & Sour Soup + Fish Cracker + 10 Pieces Wings', variants: [{ label: 'Regular', price: 1700 }] },
{ name: 'Deal 15 β Full Egg Fried Rice + Full Chicken Chow Mein + Full Chicken Chilly Dry + Full Chicken Manchurian', variants: [{ label: 'Regular', price: 2800 }] },
],
},
];
// ββ Seed logic βββββββββββββββββββββββββββββββββββββββββββββββ
async function seedMenu() {
await mongoose.connect(process.env.MONGODB_URI);
console.log('β
Connected to MongoDB Atlas\n');
let created = 0;
let skipped = 0;
for (const section of MENU_DATA) {
// Find the category by name (case-insensitive)
const category = await Category.findOne({ name: new RegExp(`^${section.category}$`, 'i') });
if (!category) {
console.warn(`β οΈ Category not found: "${section.category}" β run npm run seed first`);
continue;
}
for (const itemData of section.items) {
const exists = await MenuItem.findOne({ name: new RegExp(`^${itemData.name}$`, 'i') });
if (exists) {
console.log(` β Already exists: ${itemData.name}`);
skipped++;
continue;
}
await MenuItem.create({
name: itemData.name,
category: category._id,
available: itemData.available !== false, // default true
variants: itemData.variants.map((v) => ({ ...v, available: true })),
});
console.log(` β
${section.category} β ${itemData.name} (${itemData.variants.map((v) => `${v.label}: Rs.${v.price}`).join(', ')})`);
created++;
}
}
console.log(`\nπ Menu seed complete! Created: ${created} | Skipped: ${skipped}`);
process.exit(0);
}
seedMenu().catch((err) => {
console.error('Menu seed failed:', err);
process.exit(1);
});
|