houseofruqaapi / models /Product.js
ShieldX's picture
Upload 13 files
c0fb352 verified
raw
history blame contribute delete
985 Bytes
// models/Product.js
import mongoose from 'mongoose';
const productSchema = new mongoose.Schema({
name: {
type: String,
required: [true, 'Product name is required'],
trim: true
},
price: {
type: Number,
required: [true, 'Product price is required']
},
description: {
type: String,
required: [true, 'Product description is required']
},
fabric: {
type: String,
default: 'Premium Blend'
},
category: {
type: String,
required: true,
enum: ['Women', 'Men'] // Strictly enforces these two categories
},
subcategory: {
type: String,
required: true
},
sizes: [{
type: String
}],
images: [{
type: String, // This will store the secure Cloudinary URLs
required: true
}],
isBestseller: {
type: Boolean,
default: false
}
}, {
timestamps: true // Automatically adds createdAt and updatedAt dates
});
const Product = mongoose.model('Product', productSchema);
export default Product;