-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProduct.js
66 lines (65 loc) · 1.24 KB
/
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const productSchema = mongoose.Schema({
name: {
type: String,
trim: true,
required: true,
maxlength: 32
},
category: {
type: Schema.Types.ObjectId,
ref: 'category'
},
soldBy: {
type: Schema.Types.ObjectId,
ref: 'admin'
},
description: [{
size: {
type: String
},
color: {
type: String
},
warranty: {
type: String
},
return: {
type: String
},
weight: {
type: String
},
other:{
type: String
}
}],
images: [{
type: String
}],
price: {
type: Number,
required:true
},
discountRate: {
type: Number,//it may b float as well..
default:0
},
shipingCharge:{
type: Number
},
videoURL:[{
type:String
}],
isDeleted: {
type: Date,
default: null
},
slug: {
type: String,
slug: "name",
unique: true,
}
}, { timestamps: true });//updated pani ho?
module.exports = mongoose.model("product", productSchema);