Spaces:
Runtime error
Runtime error
Download models/orderModel.js from Beshoy-mounir/firstapp: direct link, hf CLI and curl.
- Browser
- Download file 1.2 kB
-
https://huggingface.co/spaces/Beshoy-mounir/firstapp/resolve/main/models/orderModel.js
- Command line
-
hf download hf://spaces/Beshoy-mounir/firstapp/models/orderModel.js
-
curl -L -o orderModel.js https://huggingface.co/spaces/Beshoy-mounir/firstapp/resolve/main/models/orderModel.js
1.2 kB
| const mongoose = require('mongoose'); | |
| // ------------------ | |
| // Ordered Item | |
| // ------------------ | |
| const orderItemSchema = new mongoose.Schema( | |
| { | |
| product: { | |
| type: mongoose.Schema.ObjectId, | |
| ref: 'Product', | |
| }, | |
| title: String, | |
| price: Number, | |
| quantity: Number, | |
| size: String, | |
| color: String, | |
| }, | |
| { _id: false }, | |
| ); | |
| // ------------------ | |
| // Order Schema | |
| // ------------------ | |
| const orderSchema = new mongoose.Schema( | |
| { | |
| // Modified user field to be an object | |
| user: { | |
| username: { | |
| type: String, | |
| required: true, | |
| }, | |
| userid: { | |
| type: mongoose.Schema.ObjectId, | |
| ref: 'User', | |
| required: true, | |
| }, | |
| }, | |
| items: [orderItemSchema], | |
| totalPrice: Number, | |
| status: { | |
| type: String, | |
| enum: ['pending', 'processing', 'shipped', 'completed'], | |
| default: 'pending', | |
| }, | |
| delivered: { | |
| type: Boolean, | |
| default: false, | |
| }, | |
| paid: { | |
| type: Boolean, | |
| default: false, | |
| }, | |
| shippingAddress: { | |
| city: String, | |
| street: String, | |
| phone: String, | |
| }, | |
| }, | |
| { timestamps: true }, | |
| ); | |
| module.exports = mongoose.model('Order', orderSchema); | |