53 lines
894 B
JavaScript
53 lines
894 B
JavaScript
import mongoose from "mongoose";
|
|
|
|
const productSchema = new mongoose.Schema(
|
|
{
|
|
title: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
price: {
|
|
type: Number,
|
|
required: true,
|
|
},
|
|
sales: {
|
|
type: Number,
|
|
default: 0,
|
|
},
|
|
stock: {
|
|
type: Number,
|
|
default: 0,
|
|
},
|
|
imageUrl: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
isVip: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
description: {
|
|
type: String,
|
|
default: "",
|
|
},
|
|
features: {
|
|
type: [String],
|
|
default: [],
|
|
},
|
|
services: {
|
|
type: [String],
|
|
default: ["7天无理由退货", "闪电退款", "货到付款"],
|
|
},
|
|
delivery: {
|
|
type: String,
|
|
default: "物流配送",
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
}
|
|
);
|
|
|
|
export default mongoose.models.Product ||
|
|
mongoose.model("Product", productSchema);
|