Spaces:
Running
Running
Download src/menuSeed.js from aliroohan179/face: direct link, hf CLI and curl.
- Browser
- Download file 9.25 kB
-
https://huggingface.co/spaces/aliroohan179/face/resolve/main/src/menuSeed.js
- Command line
-
hf download hf://spaces/aliroohan179/face/src/menuSeed.js
-
curl -L -o menuSeed.js https://huggingface.co/spaces/aliroohan179/face/resolve/main/src/menuSeed.js
9.25 kB
| /** | |
| * 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); | |
| }); | |