The CartItem schema will represent each product ordered. It will contain a reference to the product, the quantity of the product ordered by the user, a reference to the shop the product belongs to, and a status.
mern-marketplace/server/models/order.model.js:
const CartItemSchema = new mongoose.Schema({ product: {type: mongoose.Schema.ObjectId, ref: 'Product'}, quantity: Number, shop: {type: mongoose.Schema.ObjectId, ref: 'Shop'}, status: {type: String, default: 'Not processed', enum: ['Not processed' , 'Processing', 'Shipped', 'Delivered', 'Cancelled']}}) const CartItem = mongoose.model('CartItem', CartItemSchema)
The status of the product can only have the values as defined in the enums, representing the current state ...