Spaces:
Sleeping
Sleeping
| const mongoose = require('mongoose'); | |
| const orderSchema = new mongoose.Schema({ | |
| orderId: { type: String, required: true, unique: true }, | |
| userId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', default: null }, | |
| customer: { | |
| name: { type: String, required: true }, | |
| phone: { type: String, required: true }, | |
| email: { type: String, default: '' } | |
| }, | |
| items: [{ | |
| productId: Number, | |
| name: String, | |
| price: Number, | |
| size: String, | |
| color: String, | |
| quantity: Number, | |
| image: String | |
| }], | |
| totals: { | |
| subtotal: { type: Number, default: 0 }, | |
| discount: { type: Number, default: 0 }, | |
| total: { type: Number, default: 0 } | |
| }, | |
| paymentMethod: { type: String, default: 'cash' }, | |
| status: { type: String, default: 'Kutilmoqda', enum: ['Kutilmoqda', 'Olib ketildi', 'Bekor qilindi'] } | |
| }, { timestamps: true }); | |
| module.exports = mongoose.model('Order', orderSchema); | |