file & create: create product.model schema and add schemas to what the database need to be stored.
This commit is contained in:
1 parent
85f2d80bc9
commit
eb85e4eeab
1 file changed
+31
@@ -0,0 +1,31 @@
|
||||
import mongoose from 'mongoose';
|
||||
|
||||
const productSchema = new mongoose.Schema({
|
||||
url: {type: String, required: true, unique: true},
|
||||
currency: {type: String, required: true},
|
||||
image: { type: String, required: true},
|
||||
title: { type: String, required: true},
|
||||
currentPrice: { type: Number, required: true},
|
||||
originalPrice: { type: Number, required: true},
|
||||
priceHistory: [
|
||||
{
|
||||
price: {type: Number, required: true},
|
||||
date: {type: Date, default: Date.now}
|
||||
}
|
||||
],
|
||||
lowestPrice: {type: Number},
|
||||
highestPrice: {type: Number},
|
||||
averagePrice: {type: Number},
|
||||
discountRate: {type: Number},
|
||||
description: {type: String},
|
||||
category: {type: String},
|
||||
reviewCount: {type: Number},
|
||||
isOutOfStock: {type: Boolean, default: false},
|
||||
users: [
|
||||
{email: {type: String, required: true}}
|
||||
], default: [],
|
||||
}, {timestamps: true});
|
||||
|
||||
const Product = mongoose.models.Product || mongoose.model('Product', productSchema);
|
||||
|
||||
export default Product;
|
||||
Reference in new issue
Block a user