Database & Menu Management - hokumcangus/taste-of-aloha GitHub Wiki

🗄️ Database & Menu Management

This guide covers the three primary ways to populate and manage the menu data in the Taste of Aloha project.

1. Manual Entry (Prisma Studio)

Best for small additions or quick pricing edits.

  1. Launch Studio:
    npx prisma studio
    
  2. Action: Use the visual interface to add or edit rows in the Menu model.
  3. Verify:
    Invoke-RestMethod http://localhost:3000/api/menu | Select-Object -First 5
    

2. Bulk Import (NDJSON Shell Loop)

Ideal for importing data prepared in Line-Delimited JSON format.

  1. Prepare File (menu.ndjson):
    echo '{ "name": "Spam Musubi", "category": "Snacks", "price": 4.50 }' >> menu.ndjson
    
  2. Import:
    while IFS= read -r line; do
        curl -X POST -H "Content-Type: application/json" -d "$line" http://localhost:3000/api/menu;
    done < menu.ndjson
    

3. Scripted Import (Prisma createMany)

Best for large datasets or migrations requiring validation.

  1. Prepare JSON (menu.json):
    [
        { "name": "Lau Lau", "category": "Plates", "price": 12.99 },
        { "name": "Poke Bowl", "category": "Plates", "price": 15.50 }
    ]
    
  2. Logic:
    const menuData = require('./menu.json');
    await prisma.menu.createMany({ data: menuData });
    

💡 Pro-Tip

For the latest connectivity checks and common dev commands, always refer to the Quick Reference in the main repo.