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.
90 lines
1.7 KiB
JavaScript
90 lines
1.7 KiB
JavaScript
import mongoose from "mongoose";
|
|
|
|
const orderSchema = mongoose.Schema(
|
|
{
|
|
user: { type: mongoose.Schema.Types.ObjectId, required: true, ref: "User" },
|
|
orderItems: [
|
|
{
|
|
name: { type: String, required: true },
|
|
qty: { type: Number, required: true },
|
|
image: { type: String, required: true },
|
|
price: { type: Number, required: true },
|
|
product: {
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
required: true,
|
|
ref: "Product",
|
|
},
|
|
},
|
|
],
|
|
|
|
shippingAddress: {
|
|
address: { type: String, required: true },
|
|
city: { type: String, required: true },
|
|
postalCode: { type: String, required: true },
|
|
country: { type: String, required: true },
|
|
},
|
|
|
|
paymentMethod: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
|
|
paymentResult: {
|
|
id: { type: String },
|
|
status: { type: String },
|
|
update_time: { type: String },
|
|
email_address: { type: String },
|
|
},
|
|
|
|
itemsPrice: {
|
|
type: Number,
|
|
required: true,
|
|
default: 0.0,
|
|
},
|
|
|
|
taxPrice: {
|
|
type: Number,
|
|
required: true,
|
|
default: 0.0,
|
|
},
|
|
|
|
shippingPrice: {
|
|
type: Number,
|
|
required: true,
|
|
default: 0.0,
|
|
},
|
|
|
|
totalPrice: {
|
|
type: Number,
|
|
required: true,
|
|
default: 0.0,
|
|
},
|
|
|
|
isPaid: {
|
|
type: Boolean,
|
|
required: true,
|
|
default: false,
|
|
},
|
|
|
|
paidAt: {
|
|
type: Date,
|
|
},
|
|
|
|
isDelivered: {
|
|
type: Boolean,
|
|
required: true,
|
|
default: false,
|
|
},
|
|
|
|
deliveredAt: {
|
|
type: Date,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
}
|
|
);
|
|
|
|
const Order = mongoose.model("Order", orderSchema);
|
|
export default Order;
|