| const mongoose = require('mongoose'); |
|
|
| const reviewSchema = new mongoose.Schema({ |
| name: String, |
| rating: Number, |
| comment: String, |
| date: String, |
| location: String, |
| verifiedPurchase: Boolean, |
| helpfulVotes: Number, |
| }); |
|
|
| const imageSchema = new mongoose.Schema({ |
| image: String, |
| }); |
|
|
| const productSchema = new mongoose.Schema({ |
| name: { type: String, required: true }, |
| price: { type: Number, required: true }, |
| description: String, |
| ratings: { type: Number, min: 0, max: 5 }, |
| images: [imageSchema], |
| category: { type: String, required: true }, |
| seller: String, |
| stock: { type: Number, default: 0 }, |
| PremiumBadge: String, |
|
|
| warrantyDetails: String, |
| afterSalesSupport: String, |
| specifications: mongoose.Schema.Types.Mixed, |
| numOfReviews: { type: Number, default: 0 }, |
| reviews: [reviewSchema], |
| }, { |
| timestamps: true |
| }); |
|
|
| module.exports = mongoose.model('Product', productSchema); |