database-connector 2.5.1 → 2.5.3
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/Plan.js +30 -7
- package/models/Product.js +2 -2
- package/models/Sale.js +1 -1
- package/models/Subscription.js +18 -0
- package/models/View.js +1 -1
- package/package.json +1 -1
package/models/Plan.js
CHANGED
|
@@ -21,8 +21,17 @@ const mongoose = require('mongoose');
|
|
|
21
21
|
* type: number
|
|
22
22
|
* description: Number of months in the plan
|
|
23
23
|
* price:
|
|
24
|
-
* type:
|
|
25
|
-
*
|
|
24
|
+
* type: array
|
|
25
|
+
* items:
|
|
26
|
+
* type: object
|
|
27
|
+
* properties:
|
|
28
|
+
* currency:
|
|
29
|
+
* type: string
|
|
30
|
+
* description: Currency code (EUR, USD, DZD, etc.)
|
|
31
|
+
* amount:
|
|
32
|
+
* type: number
|
|
33
|
+
* description: Price amount in the specified currency
|
|
34
|
+
* description: Array of prices in different currencies
|
|
26
35
|
* storeReductionRules:
|
|
27
36
|
* type: array
|
|
28
37
|
* items:
|
|
@@ -49,7 +58,13 @@ const mongoose = require('mongoose');
|
|
|
49
58
|
* id: "507f1f77bcf86cd799439011"
|
|
50
59
|
* type: "Annual"
|
|
51
60
|
* months: 12
|
|
52
|
-
* price:
|
|
61
|
+
* price:
|
|
62
|
+
* - currency: "EUR"
|
|
63
|
+
* amount: 99.99
|
|
64
|
+
* - currency: "USD"
|
|
65
|
+
* amount: 109.99
|
|
66
|
+
* - currency: "DZD"
|
|
67
|
+
* amount: 13999.99
|
|
53
68
|
* storeReductionRules:
|
|
54
69
|
* - storeNumber: 2
|
|
55
70
|
* reductionPercentage: 10
|
|
@@ -71,10 +86,18 @@ const planSchema = new mongoose.Schema(
|
|
|
71
86
|
required: true,
|
|
72
87
|
unique: false
|
|
73
88
|
},
|
|
74
|
-
price:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
89
|
+
price: [
|
|
90
|
+
{
|
|
91
|
+
currency: {
|
|
92
|
+
type: String,
|
|
93
|
+
required: true,
|
|
94
|
+
},
|
|
95
|
+
amount: {
|
|
96
|
+
type: Number,
|
|
97
|
+
required: true,
|
|
98
|
+
},
|
|
99
|
+
}
|
|
100
|
+
],
|
|
78
101
|
storeReductionRules: [
|
|
79
102
|
{
|
|
80
103
|
storeNumber: {
|
package/models/Product.js
CHANGED
|
@@ -57,7 +57,7 @@ const { policySchema } = require('database-connector/models/Policy');
|
|
|
57
57
|
* description: Product tags
|
|
58
58
|
* sellerId:
|
|
59
59
|
* type: string
|
|
60
|
-
* description: Reference to seller
|
|
60
|
+
* description: Reference to seller (User model)
|
|
61
61
|
* storeId:
|
|
62
62
|
* type: string
|
|
63
63
|
* description: Reference to store
|
|
@@ -162,7 +162,7 @@ const productSchema = new mongoose.Schema(
|
|
|
162
162
|
],
|
|
163
163
|
sellerId: {
|
|
164
164
|
type: mongoose.Schema.Types.ObjectId,
|
|
165
|
-
ref: '
|
|
165
|
+
ref: 'User',
|
|
166
166
|
required: true,
|
|
167
167
|
},
|
|
168
168
|
storeId: {
|
package/models/Sale.js
CHANGED
|
@@ -37,7 +37,7 @@ const mongoose = require('mongoose');
|
|
|
37
37
|
* region: "North Region"
|
|
38
38
|
*/
|
|
39
39
|
const Sale = new mongoose.Schema({
|
|
40
|
-
sellerId: { type: mongoose.Schema.Types.ObjectId, ref: '
|
|
40
|
+
sellerId: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
|
|
41
41
|
storeId: { type: mongoose.Schema.Types.ObjectId, ref: 'Store' },
|
|
42
42
|
productId: { type: mongoose.Schema.Types.ObjectId, ref: 'Product' },
|
|
43
43
|
date: { type: Date, required: true },
|
package/models/Subscription.js
CHANGED
|
@@ -7,6 +7,7 @@ const buildSubscriptionHistorySnapshot = (subscriptionDoc) => ({
|
|
|
7
7
|
planTypeId: subscriptionDoc.planTypeId,
|
|
8
8
|
subscriptionOfferId: subscriptionDoc.subscriptionOfferId,
|
|
9
9
|
paymentAmount: subscriptionDoc.paymentAmount,
|
|
10
|
+
paymentCurrency: subscriptionDoc.paymentCurrency,
|
|
10
11
|
paymentTypeId: subscriptionDoc.paymentTypeId,
|
|
11
12
|
paymentIntentId: subscriptionDoc.paymentIntentId,
|
|
12
13
|
reductionOfferId: subscriptionDoc.reductionOfferId,
|
|
@@ -89,6 +90,10 @@ const recordSubscriptionHistory = async (oldSubscriptionDoc, updatedSubscription
|
|
|
89
90
|
* paymentAmount:
|
|
90
91
|
* type: number
|
|
91
92
|
* description: Payment amount
|
|
93
|
+
* paymentCurrency:
|
|
94
|
+
* type: string
|
|
95
|
+
* default: EUR
|
|
96
|
+
* description: Payment currency (EUR, USD, DZD, etc.)
|
|
92
97
|
* paymentTypeId:
|
|
93
98
|
* type: string
|
|
94
99
|
* description: Reference to payment type
|
|
@@ -136,6 +141,7 @@ const recordSubscriptionHistory = async (oldSubscriptionDoc, updatedSubscription
|
|
|
136
141
|
* sellerId: "507f1f77bcf86cd799439012"
|
|
137
142
|
* planId: "507f1f77bcf86cd799439013"
|
|
138
143
|
* paymentAmount: 99.99
|
|
144
|
+
* paymentCurrency: "EUR"
|
|
139
145
|
* paymentIntentId: "507f1f77bcf86cd799439099"
|
|
140
146
|
* status: "active"
|
|
141
147
|
* startDate: "2025-12-01T00:00:00.000Z"
|
|
@@ -201,6 +207,10 @@ const subscriptionSchema = new mongoose.Schema(
|
|
|
201
207
|
type: Number,
|
|
202
208
|
required: true,
|
|
203
209
|
},
|
|
210
|
+
paymentCurrency: {
|
|
211
|
+
type: String,
|
|
212
|
+
default: 'EUR',
|
|
213
|
+
},
|
|
204
214
|
paymentTypeId: {
|
|
205
215
|
type: mongoose.Schema.Types.ObjectId,
|
|
206
216
|
required: false,
|
|
@@ -266,6 +276,10 @@ const subscriptionSchema = new mongoose.Schema(
|
|
|
266
276
|
type: Number,
|
|
267
277
|
required: false,
|
|
268
278
|
},
|
|
279
|
+
paymentCurrency: {
|
|
280
|
+
type: String,
|
|
281
|
+
default: 'EUR',
|
|
282
|
+
},
|
|
269
283
|
paymentTypeId: {
|
|
270
284
|
type: mongoose.Schema.Types.ObjectId,
|
|
271
285
|
required: false,
|
|
@@ -363,6 +377,10 @@ const subscriptionSchema = new mongoose.Schema(
|
|
|
363
377
|
type: Number,
|
|
364
378
|
required: false,
|
|
365
379
|
},
|
|
380
|
+
paymentCurrency: {
|
|
381
|
+
type: String,
|
|
382
|
+
default: 'EUR',
|
|
383
|
+
},
|
|
366
384
|
paymentTypeId: {
|
|
367
385
|
type: mongoose.Schema.Types.ObjectId,
|
|
368
386
|
required: false,
|
package/models/View.js
CHANGED
|
@@ -41,7 +41,7 @@ const mongoose = require('mongoose');
|
|
|
41
41
|
* region: "North Region"
|
|
42
42
|
*/
|
|
43
43
|
const viewsSchema = new mongoose.Schema({
|
|
44
|
-
sellerId: { type: mongoose.Schema.Types.ObjectId, ref: '
|
|
44
|
+
sellerId: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
|
|
45
45
|
clientId: { type: mongoose.Schema.Types.ObjectId, ref: 'Client' },
|
|
46
46
|
storeId: { type: mongoose.Schema.Types.ObjectId, ref: 'Store' },
|
|
47
47
|
productId: { type: mongoose.Schema.Types.ObjectId, ref: 'Product' },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "database-connector",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.3",
|
|
4
4
|
"description": "MongoDB models package with Mongoose schemas for e-commerce applications. Includes User, Product, Store, Order and more with built-in validation and virtual properties.",
|
|
5
5
|
"main": "models/index.js",
|
|
6
6
|
"scripts": {
|