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.
34 lines
504 B
JavaScript
34 lines
504 B
JavaScript
10 months ago
|
const mongoose = require("mongoose");
|
||
|
|
||
|
|
||
|
const orderSchema = new mongoose.Schema({
|
||
|
userId: {
|
||
|
type: String
|
||
|
},
|
||
|
products : [
|
||
|
{
|
||
|
productId: {
|
||
|
type: String,
|
||
|
required: [true, "Product id is required!"]
|
||
|
},
|
||
|
quantity : {
|
||
|
type : Number,
|
||
|
default : 1
|
||
|
},
|
||
|
price:{
|
||
|
type: Number
|
||
|
}
|
||
|
}
|
||
|
],
|
||
|
totalAmount: {
|
||
|
type: Number,
|
||
|
},
|
||
|
purchasedOn : {
|
||
|
type: Date,
|
||
|
default : new Date()
|
||
|
}
|
||
|
})
|
||
|
|
||
|
const Order = mongoose.model("orders", orderSchema);
|
||
|
|
||
|
module.exports = Order;
|