-
Notifications
You must be signed in to change notification settings - Fork 144
/
Copy pathProduct.js
25 lines (23 loc) · 822 Bytes
/
Product.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import mongoose from "mongoose";
const productSchema = new mongoose.Schema(
{
name: { type: String, required: true },
slug: { type: String, required: true, unique: true },
category: { type: String, required: true },
image: { type: String, required: true },
price: { type: Number, required: true },
brand: { type: String, required: true },
rating: { type: Number, required: true, default: 0 },
numReviews: { type: Number, required: true, default: 0 },
countInStock: { type: Number, required: true, default: 0 },
description: { type: String, required: true },
isFeatured: { type: Boolean, default: false },
banner: String,
},
{
timestamps: true,
}
);
const Product =
mongoose.models.Product || mongoose.model("Product", productSchema);
export default Product;