Untitled
unknown
plain_text
24 days ago
1.7 kB
3
Indexable
Never
const mongoose = require('mongoose'); const orderSchema = new mongoose.Schema({ products: [ { product: { type: mongoose.Schema.Types.ObjectId, ref: 'Product', required: true }, quantity: { type: Number, required: true }, price: { type: Number, required: true }, initialPrice: { type: Number, required: true } } ], ordered_by: { type: mongoose.Schema.Types.ObjectId, required: true }, nb_tracking: { type: String, required: true }, nb_colis: { type: Number, min:1, required: true }, shipping: { method: { type: String // required: true }, cost: { type: Number // required: true } }, cart_address: { first_name: { type: String, required: true }, last_name: { type: String, required: true }, phone: { type: String, required: true }, city: { type: String, required: true }, zipCode: { type: Number, required: true }, address: { type: String, required: true } }, totalPrice: { type: Number // required: true }, status: { type: String, enum: ['pending', 'processing', 'cancel', 'delivered'], default: 'pending' }, createdAt: { type: Date, default: Date.now }, updatedAt: { type: Date, default: Date.now } }); const Order = mongoose.model('Order', orderSchema); module.exports = Order;
Leave a Comment