database-connector 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/models/Bill.js +110 -0
- package/models/Cart.js +57 -0
- package/models/Category.js +33 -0
- package/models/FlashDeal.js +63 -0
- package/models/Notification.js +35 -0
- package/models/Offer.js +76 -0
- package/models/Order.js +217 -0
- package/models/OrderOld.js +74 -0
- package/models/Payment.js +117 -0
- package/models/PaymentType.js +14 -0
- package/models/Plan.js +42 -0
- package/models/Policy.js +94 -0
- package/models/Product.js +197 -0
- package/models/ReductionOffer.js +89 -0
- package/models/ResetPassword.js +23 -0
- package/models/Sale.js +11 -0
- package/models/Store.js +260 -0
- package/models/StoreCategory.js +15 -0
- package/models/StoreRate.js +23 -0
- package/models/Subscription.js +129 -0
- package/models/SubscriptionOffer.js +18 -0
- package/models/User.js +211 -0
- package/models/View.js +13 -0
- package/models/index.js +35 -0
- package/package.json +15 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
var ObjectId = require('mongodb').ObjectID;
|
|
3
|
+
|
|
4
|
+
const paymentSchema = new mongoose.Schema(
|
|
5
|
+
{
|
|
6
|
+
userId: {
|
|
7
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
8
|
+
required: true,
|
|
9
|
+
ref: 'User',
|
|
10
|
+
},
|
|
11
|
+
sellerId: {
|
|
12
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
13
|
+
required: true,
|
|
14
|
+
ref: 'User',
|
|
15
|
+
},
|
|
16
|
+
gateway: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
paymentStatus: {
|
|
22
|
+
type: String,
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
25
|
+
paymentAmount: {
|
|
26
|
+
type: Number,
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
paymentCurrency: {
|
|
30
|
+
type: String,
|
|
31
|
+
required: true,
|
|
32
|
+
},
|
|
33
|
+
paymentMethod: {
|
|
34
|
+
type: String,
|
|
35
|
+
required: true,
|
|
36
|
+
},
|
|
37
|
+
paymentDate: {
|
|
38
|
+
type: Date,
|
|
39
|
+
required: true,
|
|
40
|
+
},
|
|
41
|
+
paymentTime: {
|
|
42
|
+
type: Date,
|
|
43
|
+
required: true,
|
|
44
|
+
},
|
|
45
|
+
paymentDetails: {
|
|
46
|
+
type: Object,
|
|
47
|
+
required: true,
|
|
48
|
+
},
|
|
49
|
+
totalPrice: {
|
|
50
|
+
type: Number,
|
|
51
|
+
required: true,
|
|
52
|
+
default: 0,
|
|
53
|
+
},
|
|
54
|
+
card: {
|
|
55
|
+
brand: {
|
|
56
|
+
type: String,
|
|
57
|
+
required: true,
|
|
58
|
+
},
|
|
59
|
+
last4: {
|
|
60
|
+
type: String,
|
|
61
|
+
required: true,
|
|
62
|
+
},
|
|
63
|
+
exp_month: {
|
|
64
|
+
type: Number,
|
|
65
|
+
required: true,
|
|
66
|
+
},
|
|
67
|
+
exp_year: {
|
|
68
|
+
type: Number,
|
|
69
|
+
required: true,
|
|
70
|
+
},
|
|
71
|
+
funding: {
|
|
72
|
+
type: String,
|
|
73
|
+
required: true,
|
|
74
|
+
},
|
|
75
|
+
country: {
|
|
76
|
+
type: String,
|
|
77
|
+
required: true,
|
|
78
|
+
},
|
|
79
|
+
name: {
|
|
80
|
+
type: String,
|
|
81
|
+
required: true,
|
|
82
|
+
},
|
|
83
|
+
address_line1: {
|
|
84
|
+
type: String,
|
|
85
|
+
required: true,
|
|
86
|
+
},
|
|
87
|
+
address_line2: {
|
|
88
|
+
type: String,
|
|
89
|
+
required: true,
|
|
90
|
+
},
|
|
91
|
+
address_city: {
|
|
92
|
+
type: String,
|
|
93
|
+
required: true,
|
|
94
|
+
},
|
|
95
|
+
ccvVerified: {
|
|
96
|
+
type: Boolean,
|
|
97
|
+
required: true,
|
|
98
|
+
default: false,
|
|
99
|
+
},
|
|
100
|
+
ccv: {
|
|
101
|
+
type: String,
|
|
102
|
+
required: true,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
timestamps: {
|
|
106
|
+
type: Date,
|
|
107
|
+
required: true,
|
|
108
|
+
default: Date.now(),
|
|
109
|
+
},
|
|
110
|
+
token: {
|
|
111
|
+
type: String,
|
|
112
|
+
required: true,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
{ timestamps: true }
|
|
116
|
+
);
|
|
117
|
+
module.exports = mongoose.model('Payment', paymentSchema);
|
package/models/Plan.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const planSchema = new mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
type: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true,
|
|
8
|
+
unique: false,
|
|
9
|
+
validate: {
|
|
10
|
+
validator: function (value) {
|
|
11
|
+
const predefinedTypes = ['Annual', 'Semi-annual', 'Quarterly', 'Monthly'];
|
|
12
|
+
return predefinedTypes.includes(value) || /^[a-zA-Z\s]+$/.test(value);
|
|
13
|
+
},
|
|
14
|
+
message: props => `${props.value} is not a valid plan type!`
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
months: {
|
|
18
|
+
type: Number,
|
|
19
|
+
required: true,
|
|
20
|
+
unique: false
|
|
21
|
+
},
|
|
22
|
+
price: {
|
|
23
|
+
type: Number,
|
|
24
|
+
required: true,
|
|
25
|
+
},
|
|
26
|
+
reductionOffers: [
|
|
27
|
+
{
|
|
28
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
29
|
+
ref: 'ReductionOffer'
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
status: {
|
|
33
|
+
type: String,
|
|
34
|
+
enum: ['active', 'suspended'],
|
|
35
|
+
default: 'active',
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
},
|
|
39
|
+
{}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
module.exports = mongoose.model('Plan', planSchema);
|
package/models/Policy.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const { Schema, model } = require('mongoose');
|
|
2
|
+
|
|
3
|
+
exports.policySchema = new Schema(
|
|
4
|
+
{
|
|
5
|
+
|
|
6
|
+
workingTime : {
|
|
7
|
+
type : {
|
|
8
|
+
openTime: { type: String , default : ""},
|
|
9
|
+
closeTime: { type: String , default : ""} ,
|
|
10
|
+
} ,
|
|
11
|
+
},
|
|
12
|
+
pickup: {
|
|
13
|
+
type : {
|
|
14
|
+
timeLimit : { type: Number , default : null} ,
|
|
15
|
+
} ,
|
|
16
|
+
},
|
|
17
|
+
delivery: {
|
|
18
|
+
type : {
|
|
19
|
+
delivery : {type : Boolean, default : null } ,
|
|
20
|
+
zone : {
|
|
21
|
+
centerPoint : {
|
|
22
|
+
latitude : { type : Number , default : null} ,
|
|
23
|
+
longitude : { type : Number , default : null} ,
|
|
24
|
+
} ,
|
|
25
|
+
radius : { type : Number , default : null } ,
|
|
26
|
+
} ,
|
|
27
|
+
pricing : {
|
|
28
|
+
fixe : {type : Number , default : null} ,
|
|
29
|
+
km : {type : Number , default : null} ,
|
|
30
|
+
} ,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
} ,
|
|
34
|
+
|
|
35
|
+
reservation : {
|
|
36
|
+
type : {
|
|
37
|
+
duration : {type : Number , default : null} ,
|
|
38
|
+
payment : {
|
|
39
|
+
free : {type : Boolean , default : null} ,
|
|
40
|
+
partial : {
|
|
41
|
+
fixe : {type : Number , default : null} ,
|
|
42
|
+
percentage : {type : Number , default : null} ,
|
|
43
|
+
} ,
|
|
44
|
+
total : {type : Boolean , default : null} ,
|
|
45
|
+
} ,
|
|
46
|
+
cancelation : {
|
|
47
|
+
restrictions : {
|
|
48
|
+
fixe : {type : Number , default : null} ,
|
|
49
|
+
percentage : {type : Number , default : null} ,
|
|
50
|
+
}
|
|
51
|
+
} ,
|
|
52
|
+
} ,
|
|
53
|
+
} ,
|
|
54
|
+
return : {
|
|
55
|
+
type : {
|
|
56
|
+
duration : {type : Number , default : null} ,
|
|
57
|
+
productStatus : {type : String , default : ""} ,
|
|
58
|
+
returnMethod : {type : String , default : ""} ,
|
|
59
|
+
refund : {
|
|
60
|
+
order : {
|
|
61
|
+
fixe : {type : Number , default : null} ,
|
|
62
|
+
percentage : {type : Number , default : null} ,
|
|
63
|
+
} ,
|
|
64
|
+
shipping : {
|
|
65
|
+
fixe : {type : Number , default : null} ,
|
|
66
|
+
percentage : {type : Number , default : null} ,
|
|
67
|
+
},
|
|
68
|
+
} ,
|
|
69
|
+
} ,
|
|
70
|
+
|
|
71
|
+
} ,
|
|
72
|
+
order : {
|
|
73
|
+
type : {
|
|
74
|
+
|
|
75
|
+
notification : {
|
|
76
|
+
realtime :{type : Boolean , default : null} ,
|
|
77
|
+
time :{type : Number , default : null} ,
|
|
78
|
+
perOrdersNbr :{type : Number , default : null} ,
|
|
79
|
+
sendMode : {
|
|
80
|
+
mail :{type : Boolean , default : null} ,
|
|
81
|
+
sms :{type : Boolean , default : null} ,
|
|
82
|
+
popup :{type : Boolean , default : null} ,
|
|
83
|
+
vibration :{type : Boolean , default : null} ,
|
|
84
|
+
ringing :{type : Boolean , default : null} ,
|
|
85
|
+
} ,
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
);
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
const { policySchema } = require('./Policy');
|
|
3
|
+
var ObjectId = require('mongodb').ObjectID;
|
|
4
|
+
|
|
5
|
+
const productSchema = new mongoose.Schema(
|
|
6
|
+
{
|
|
7
|
+
name: {
|
|
8
|
+
type: String,
|
|
9
|
+
required: true,
|
|
10
|
+
},
|
|
11
|
+
description: { type: String, required: true },
|
|
12
|
+
price: { type: Number, required: true },
|
|
13
|
+
storeCategoryId : {
|
|
14
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
15
|
+
ref: 'StoreCategory',
|
|
16
|
+
required: true,
|
|
17
|
+
} ,
|
|
18
|
+
categoryId: {
|
|
19
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
20
|
+
ref: 'Category',
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
subCategoryId: {
|
|
24
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
25
|
+
//required: true,
|
|
26
|
+
},
|
|
27
|
+
rayonId: {
|
|
28
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
29
|
+
required: true,
|
|
30
|
+
},
|
|
31
|
+
//customCategory: { type: String, required: true },
|
|
32
|
+
//customCategoryId: { type: String, required: true },
|
|
33
|
+
images: [{ type: String, required: true }],
|
|
34
|
+
tags: [{ type: String, required: true }],
|
|
35
|
+
variants: [
|
|
36
|
+
{
|
|
37
|
+
characterstics: {
|
|
38
|
+
type: Object,
|
|
39
|
+
required: true,
|
|
40
|
+
},
|
|
41
|
+
price: {
|
|
42
|
+
type: Number,
|
|
43
|
+
required: true,
|
|
44
|
+
},
|
|
45
|
+
quantity: {
|
|
46
|
+
type: Number,
|
|
47
|
+
required: true,
|
|
48
|
+
default: 1,
|
|
49
|
+
},
|
|
50
|
+
img: {
|
|
51
|
+
type: String,
|
|
52
|
+
//required: true,
|
|
53
|
+
},
|
|
54
|
+
available: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
required: true,
|
|
57
|
+
default: true,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
sellerId: {
|
|
62
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
63
|
+
ref: 'Seller',
|
|
64
|
+
required: true,
|
|
65
|
+
},
|
|
66
|
+
storeId: {
|
|
67
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
68
|
+
ref: 'Store',
|
|
69
|
+
required: true,
|
|
70
|
+
},
|
|
71
|
+
deleted: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
required: true,
|
|
74
|
+
default: false,
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
discountCode: {
|
|
78
|
+
type: String,
|
|
79
|
+
},
|
|
80
|
+
discount: {
|
|
81
|
+
type: Number,
|
|
82
|
+
default: 0,
|
|
83
|
+
},
|
|
84
|
+
discountType: {
|
|
85
|
+
type: String,
|
|
86
|
+
enum: ['percentage', 'amount'],
|
|
87
|
+
},
|
|
88
|
+
discountExpiration: {
|
|
89
|
+
type: Date,
|
|
90
|
+
required: true,
|
|
91
|
+
default: Date.now() + 86400000,
|
|
92
|
+
},
|
|
93
|
+
flashDeal: {
|
|
94
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
95
|
+
ref: 'FlashDeal',
|
|
96
|
+
},
|
|
97
|
+
offer: {
|
|
98
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
99
|
+
ref: 'Offer',
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
numberOfSales: {
|
|
104
|
+
type: Number,
|
|
105
|
+
default: 0,
|
|
106
|
+
},
|
|
107
|
+
numberOfViews: {
|
|
108
|
+
type: Number,
|
|
109
|
+
default: 0,
|
|
110
|
+
},
|
|
111
|
+
numberOfSearches: {
|
|
112
|
+
type: Number,
|
|
113
|
+
default: 0,
|
|
114
|
+
},
|
|
115
|
+
averageRating: {
|
|
116
|
+
type: Number,
|
|
117
|
+
default: 0,
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
reports: [
|
|
121
|
+
{
|
|
122
|
+
idUser: {
|
|
123
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
124
|
+
ref: 'User',
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
message: { type: String },
|
|
128
|
+
|
|
129
|
+
date: {
|
|
130
|
+
type: Date,
|
|
131
|
+
required: true,
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
policy: policySchema,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
timestamp: true,
|
|
139
|
+
toJSON: { virtuals: true },
|
|
140
|
+
}
|
|
141
|
+
);/*
|
|
142
|
+
productSchema.virtual('quantity').get(function () {
|
|
143
|
+
const variants = this.variants;
|
|
144
|
+
return variants.reduce(function (total, currentValue) {
|
|
145
|
+
return total + currentValue.quantity;
|
|
146
|
+
}, 0);
|
|
147
|
+
});
|
|
148
|
+
productSchema.virtual('PriceMin').get(function () {
|
|
149
|
+
const variants = this.variants;
|
|
150
|
+
return variants.reduce(function (prev, curr) {
|
|
151
|
+
return prev.price < curr.price ? prev : curr;
|
|
152
|
+
}).price;
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
productSchema.virtual('PriceMax').get(function () {
|
|
156
|
+
const variants = this.variants;
|
|
157
|
+
return variants.reduce(function (prev, curr) {
|
|
158
|
+
return prev.price > curr.price ? prev : curr;
|
|
159
|
+
}).price;
|
|
160
|
+
});*/
|
|
161
|
+
//virtual array of all the images of the product
|
|
162
|
+
productSchema.virtual('imagesss').get(function () {
|
|
163
|
+
if (this.images != null) {
|
|
164
|
+
const images = this.images;
|
|
165
|
+
console.log(images);
|
|
166
|
+
console.log('images');
|
|
167
|
+
return images.map(function (image) {
|
|
168
|
+
return `${process.env.APP_URL}/${image}`;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
productSchema.virtual('discounted').get(function () {
|
|
173
|
+
if (this.offer) {
|
|
174
|
+
console.log('Disount')
|
|
175
|
+
|
|
176
|
+
return this.offer.discount;
|
|
177
|
+
|
|
178
|
+
} else {
|
|
179
|
+
return this.price;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
//virtual array for all the images of the variants
|
|
183
|
+
productSchema.virtual('variantImages').get(function () {
|
|
184
|
+
if (this.variants != null) {
|
|
185
|
+
const variants = this.variants;
|
|
186
|
+
console.log(variants);
|
|
187
|
+
return variants.map(function (variant) {
|
|
188
|
+
if (variant.img != null) {
|
|
189
|
+
return `${process.env.APP_URL}/${variant.img}`;
|
|
190
|
+
} else {
|
|
191
|
+
return `${process.env.APP_URL}/images/default.png`;
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
module.exports = mongoose.model('Product', productSchema);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const ReductionOfferSchema = new mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
name: {
|
|
6
|
+
type: String,
|
|
7
|
+
unique: true,
|
|
8
|
+
required: true,
|
|
9
|
+
},
|
|
10
|
+
discount: {
|
|
11
|
+
type: Number,
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
storesNumber: {
|
|
15
|
+
type: Number,
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
plan: {
|
|
19
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
20
|
+
required: true,
|
|
21
|
+
ref: 'Plan',
|
|
22
|
+
},
|
|
23
|
+
StartDate: {
|
|
24
|
+
type: Date,
|
|
25
|
+
required: false,
|
|
26
|
+
},
|
|
27
|
+
EndDate: {
|
|
28
|
+
type: Date,
|
|
29
|
+
required: false,
|
|
30
|
+
},
|
|
31
|
+
description: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: false,
|
|
34
|
+
},
|
|
35
|
+
status: {
|
|
36
|
+
type: String,
|
|
37
|
+
enum: ['inactive', 'active', 'expired'],
|
|
38
|
+
default: 'inactive',
|
|
39
|
+
},
|
|
40
|
+
plan: {
|
|
41
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
42
|
+
ref: 'Plan',
|
|
43
|
+
required: true
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{ timestamps: true }
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// Pre-save hook to ensure only one offer is active at a time
|
|
50
|
+
ReductionOfferSchema.pre('save', async function (next) {
|
|
51
|
+
const offer = this;
|
|
52
|
+
|
|
53
|
+
// If the current offer is being set to active
|
|
54
|
+
if (offer.status === 'active') {
|
|
55
|
+
// Find the currently active offer
|
|
56
|
+
const activeOffer = await mongoose.model('ReductionOffer').findOne({ status: 'active' });
|
|
57
|
+
|
|
58
|
+
// If another active offer is found and it's not the current offer being updated
|
|
59
|
+
if (activeOffer && activeOffer._id.toString() !== offer._id.toString()) {
|
|
60
|
+
// Set the old active offer to inactive
|
|
61
|
+
activeOffer.status = 'inactive';
|
|
62
|
+
await activeOffer.save();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
next();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Pre-update hook to ensure only one offer is active at a time
|
|
70
|
+
ReductionOfferSchema.pre('findOneAndUpdate', async function (next) {
|
|
71
|
+
const update = this.getUpdate();
|
|
72
|
+
|
|
73
|
+
// If the status is being set to active
|
|
74
|
+
if (update.status === 'active') {
|
|
75
|
+
// Find the currently active offer
|
|
76
|
+
const activeOffer = await mongoose.model('ReductionOffer').findOne({ status: 'active' });
|
|
77
|
+
|
|
78
|
+
// If another active offer is found and it's not the current offer being updated
|
|
79
|
+
if (activeOffer && activeOffer._id.toString() !== this.getQuery()._id.toString()) {
|
|
80
|
+
// Set the old active offer to inactive
|
|
81
|
+
activeOffer.status = 'inactive';
|
|
82
|
+
await activeOffer.save();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
next();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
module.exports = mongoose.model('ReductionOffer', ReductionOfferSchema);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const resetPasswordSchema = new mongoose.Schema(
|
|
4
|
+
{
|
|
5
|
+
userId: {
|
|
6
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
7
|
+
required: true,
|
|
8
|
+
ref: 'User',
|
|
9
|
+
},
|
|
10
|
+
token: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
createAt: {
|
|
15
|
+
type: Date,
|
|
16
|
+
default: Date.now,
|
|
17
|
+
expires : 3600
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{ toJSON: { virtuals: true } }
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
module.exports = mongoose.model('ResetPassword', resetPasswordSchema);
|
package/models/Sale.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const Sale = new mongoose.Schema({
|
|
4
|
+
sellerId: { type: mongoose.Schema.Types.ObjectId, ref: 'Seller' },
|
|
5
|
+
storeId: { type: mongoose.Schema.Types.ObjectId, ref: 'Store' },
|
|
6
|
+
productId: { type: mongoose.Schema.Types.ObjectId, ref: 'Product' },
|
|
7
|
+
date: { type: Date, required: true },
|
|
8
|
+
region: { type: String }, // If you want to track region for each sale
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
module.exports = mongoose.model('Sale', Sale);
|