Spaces:
Running
Running
feat: implement core backend POS API with authentication, role-based access control, menu management, and order processing logic.
1e480b5 Download src/models/MenuItem.js from aliroohan179/face: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/spaces/aliroohan179/face/resolve/main/src/models/MenuItem.js
- Command line
-
hf download hf://spaces/aliroohan179/face/src/models/MenuItem.js
-
curl -L -o MenuItem.js https://huggingface.co/spaces/aliroohan179/face/resolve/main/src/models/MenuItem.js
1.11 kB
| const mongoose = require('mongoose'); | |
| const variantSchema = new mongoose.Schema( | |
| { | |
| label: { type: String, required: true, trim: true }, // e.g. "Half", "Full", "1 Litre" | |
| price: { type: Number, required: true, min: 0 }, | |
| available: { type: Boolean, default: true }, | |
| }, | |
| { _id: true } | |
| ); | |
| const menuItemSchema = new mongoose.Schema( | |
| { | |
| name: { type: String, required: true, trim: true }, | |
| category: { type: mongoose.Schema.Types.ObjectId, ref: 'Category', required: true }, | |
| image: { type: String, default: null }, // Cloudinary URL | |
| available: { type: Boolean, default: true }, | |
| // Variants: every dish has at least one variant. | |
| // Single-price dish → one variant with label "Regular" or blank. | |
| // Deal → one variant with a fixed price, category = Deals category. | |
| variants: { type: [variantSchema], required: true, validate: [(v) => v.length > 0, 'At least one variant required'] }, | |
| }, | |
| { timestamps: true } | |
| ); | |
| // Index for fast menu-all query | |
| menuItemSchema.index({ category: 1, available: 1 }); | |
| module.exports = mongoose.model('MenuItem', menuItemSchema); | |