You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
612 B
JavaScript
42 lines
612 B
JavaScript
1 year ago
|
const mongoose = require("mongoose");
|
||
|
|
||
|
const orderSchema = new mongoose.Schema({
|
||
|
|
||
|
|
||
|
userId: {
|
||
|
type: String,
|
||
|
required: true
|
||
|
},
|
||
|
products: [
|
||
|
{
|
||
|
productId: {
|
||
|
type: String,
|
||
|
required: true,
|
||
|
},
|
||
|
quantity: {
|
||
|
type: Number,
|
||
|
required: true,
|
||
|
}
|
||
|
}
|
||
|
],
|
||
|
price: {
|
||
|
type: Number,
|
||
|
required: true
|
||
|
},
|
||
|
|
||
|
totalAmount: {
|
||
|
type: Number,
|
||
|
required: true
|
||
|
},
|
||
|
description: {
|
||
|
type: String,
|
||
|
required: true
|
||
|
},
|
||
|
purchasedOnDate: {
|
||
|
type: Date,
|
||
|
default: Date.now
|
||
|
}
|
||
|
});
|
||
|
|
||
|
module.exports = mongoose.model('Order', orderSchema);
|