database-connector 2.2.7 → 2.2.9

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/Order.js CHANGED
@@ -29,9 +29,22 @@ const { policySchema } = require('./Policy');
29
29
  * description: Reference to the store
30
30
  * pickupPerson:
31
31
  * type: object
32
+ * nullable: true
32
33
  * properties:
33
34
  * name:
34
35
  * type: string
36
+ * deliveryLocation:
37
+ * type: object
38
+ * properties:
39
+ * type:
40
+ * type: string
41
+ * enum: [Point]
42
+ * coordinates:
43
+ * type: array
44
+ * items:
45
+ * type: number
46
+ * minItems: 2
47
+ * maxItems: 2
35
48
  * deliveryAddresse:
36
49
  * type: object
37
50
  * properties:
@@ -43,12 +56,28 @@ const { policySchema } = require('./Policy');
43
56
  * type: string
44
57
  * country:
45
58
  * type: string
59
+ * fullAdress:
60
+ * type: string
46
61
  * region:
47
62
  * type: string
63
+ * countryCode:
64
+ * type: string
65
+ * phone:
66
+ * type: string
67
+ * distance:
68
+ * type: number
69
+ * nullable: true
48
70
  * items:
49
71
  * type: array
50
72
  * items:
51
73
  * type: object
74
+ * required:
75
+ * - productId
76
+ * - variantId
77
+ * - price
78
+ * - discount
79
+ * - discountType
80
+ * - quantity
52
81
  * properties:
53
82
  * productId:
54
83
  * type: string
@@ -56,33 +85,158 @@ const { policySchema } = require('./Policy');
56
85
  * type: string
57
86
  * name:
58
87
  * type: string
88
+ * image:
89
+ * type: string
59
90
  * price:
60
91
  * type: number
92
+ * discount:
93
+ * type: number
94
+ * discountType:
95
+ * type: string
96
+ * enum: [percentage, amount]
97
+ * reservation:
98
+ * type: number
61
99
  * quantity:
62
100
  * type: number
101
+ * default: 1
102
+ * policy:
103
+ * type: object
104
+ * offerId:
105
+ * type: string
106
+ * nullable: true
107
+ * refund:
108
+ * type: object
109
+ * properties:
110
+ * order:
111
+ * type: object
112
+ * properties:
113
+ * fixe:
114
+ * type: number
115
+ * nullable: true
116
+ * percentage:
117
+ * type: number
118
+ * nullable: true
119
+ * shipping:
120
+ * type: object
121
+ * properties:
122
+ * fixe:
123
+ * type: number
124
+ * nullable: true
125
+ * percentage:
126
+ * type: number
127
+ * nullable: true
128
+ * promoDealId:
129
+ * type: string
130
+ * nullable: true
131
+ * description: Reference to FlashDeal
132
+ * return:
133
+ * type: boolean
134
+ * nullable: true
135
+ * returnItems:
136
+ * type: array
137
+ * items:
138
+ * type: object
139
+ * properties:
140
+ * productId:
141
+ * type: string
142
+ * variantId:
143
+ * type: string
144
+ * name:
145
+ * type: string
146
+ * image:
147
+ * type: string
148
+ * price:
149
+ * type: number
63
150
  * discount:
64
151
  * type: number
65
152
  * discountType:
66
153
  * type: string
67
154
  * enum: [percentage, amount]
155
+ * quantity:
156
+ * type: number
157
+ * orderQuantity:
158
+ * type: number
159
+ * policy:
160
+ * type: object
161
+ * returnedItems:
162
+ * type: array
163
+ * items:
164
+ * type: object
165
+ * properties:
166
+ * productId:
167
+ * type: string
168
+ * variantId:
169
+ * type: string
170
+ * name:
171
+ * type: string
172
+ * image:
173
+ * type: string
174
+ * price:
175
+ * type: number
176
+ * discount:
177
+ * type: number
178
+ * discountType:
179
+ * type: string
180
+ * enum: [percentage, amount]
181
+ * quantity:
182
+ * type: number
183
+ * orderQuantity:
184
+ * type: number
185
+ * policy:
186
+ * type: object
187
+ * refundPaymentInfos:
188
+ * type: object
189
+ * nullable: true
190
+ * properties:
191
+ * totalAmount:
192
+ * type: number
193
+ * returnMotif:
194
+ * type: string
195
+ * nullable: true
196
+ * waitingforReturn:
197
+ * type: boolean
198
+ * nullable: true
199
+ * returned:
200
+ * type: boolean
201
+ * nullable: true
68
202
  * paymentInfos:
69
203
  * type: object
204
+ * required:
205
+ * - totalAmount
206
+ * - paymentMethodId
70
207
  * properties:
71
208
  * totalAmount:
72
209
  * type: number
73
210
  * paymentMethodId:
74
- * type: number
211
+ * type: string
212
+ * description: Reference to PaymentType
75
213
  * paymentIntentId:
76
- * type: number
214
+ * type: string
215
+ * nullable: true
216
+ * description: Reference to Payment
77
217
  * pickUp:
78
218
  * type: boolean
79
219
  * description: Whether order is pickup
80
220
  * delivery:
81
221
  * type: boolean
82
222
  * description: Whether order is delivery
223
+ * refund:
224
+ * type: boolean
225
+ * nullable: true
226
+ * timeLimit:
227
+ * type: number
228
+ * nullable: true
83
229
  * canceled:
84
230
  * type: boolean
231
+ * nullable: true
85
232
  * description: Whether order is canceled
233
+ * canceledBy:
234
+ * type: object
235
+ * properties:
236
+ * userId:
237
+ * type: string
238
+ * motif:
239
+ * type: string
86
240
  * status:
87
241
  * type: string
88
242
  * enum: [Pending, Payed, InPreparation, LoadingDelivery, OnTheWay, Delivered, AwaitingRecovery, Recovered, Reserved, WaitingForReturn, Returned, UnderRefund, Refunded, succeeded]
@@ -101,6 +255,7 @@ const { policySchema } = require('./Policy');
101
255
  * status: "Pending"
102
256
  * pickUp: false
103
257
  * delivery: true
258
+ * distance: 5.2
104
259
  * createdAt: "2025-12-07T10:30:00.000Z"
105
260
  * updatedAt: "2025-12-07T10:30:00.000Z"
106
261
  */
@@ -189,6 +344,12 @@ const orderSchema = new mongoose.Schema(
189
344
  reservation: { type: Number },
190
345
  quantity: { type: Number, required: true, default: 1 },
191
346
  policy: policySchema,
347
+ offerId: {
348
+ type: mongoose.Schema.Types.ObjectId,
349
+ required: false,
350
+ ref: 'Offer',
351
+ default: null
352
+ },
192
353
 
193
354
  refund: {
194
355
  order: {
@@ -206,7 +367,12 @@ const orderSchema = new mongoose.Schema(
206
367
  timestamps: true,
207
368
  },
208
369
  ],
209
-
370
+ promoDealId: {
371
+ type: mongoose.Schema.Types.ObjectId,
372
+ required: false,
373
+ ref: 'FlashDeal',
374
+ default: null
375
+ },
210
376
 
211
377
  return: { type: Boolean, default: null },
212
378
 
package/models/Payment.js CHANGED
@@ -7,8 +7,6 @@ const mongoose = require('mongoose');
7
7
  * Payment:
8
8
  * type: object
9
9
  * required:
10
- * - userId
11
- * - sellerId
12
10
  * - gateway
13
11
  * - paymentStatus
14
12
  * - paymentAmount
@@ -21,12 +19,14 @@ const mongoose = require('mongoose');
21
19
  * id:
22
20
  * type: string
23
21
  * description: The payment identifier
24
- * userId:
22
+ * creatorId:
25
23
  * type: string
26
- * description: Reference to the user
27
- * sellerId:
24
+ * nullable: true
25
+ * description: Reference to the payment creator (user)
26
+ * ownerId:
28
27
  * type: string
29
- * description: Reference to the seller
28
+ * nullable: true
29
+ * description: Reference to the payment owner
30
30
  * gateway:
31
31
  * type: string
32
32
  * description: Payment gateway used
@@ -66,8 +66,8 @@ const mongoose = require('mongoose');
66
66
  * format: date-time
67
67
  * example:
68
68
  * id: "507f1f77bcf86cd799439011"
69
- * userId: "507f1f77bcf86cd799439012"
70
- * sellerId: "507f1f77bcf86cd799439013"
69
+ * creatorId: "507f1f77bcf86cd799439012"
70
+ * ownerId: "507f1f77bcf86cd799439013"
71
71
  * gateway: "Stripe"
72
72
  * paymentStatus: "succeeded"
73
73
  * paymentAmount: 150.00
@@ -79,14 +79,16 @@ const mongoose = require('mongoose');
79
79
  */
80
80
  const paymentSchema = new mongoose.Schema(
81
81
  {
82
- userId: {
82
+ creatorId: {
83
83
  type: mongoose.Schema.Types.ObjectId,
84
- required: true,
84
+ required: false,
85
+ default: null,
85
86
  ref: 'User',
86
87
  },
87
- sellerId: {
88
+ ownerId: {
88
89
  type: mongoose.Schema.Types.ObjectId,
89
- required: true,
90
+ required: false,
91
+ default: null,
90
92
  ref: 'User',
91
93
  },
92
94
  gateway: {
@@ -144,8 +146,8 @@ const paymentSchema = new mongoose.Schema(
144
146
  );
145
147
 
146
148
  // Indexes for performance optimization
147
- paymentSchema.index({ userId: 1, createdAt: -1 });
148
- paymentSchema.index({ sellerId: 1, createdAt: -1 });
149
+ paymentSchema.index({ creatorId: 1, createdAt: -1 });
150
+ paymentSchema.index({ ownerId: 1, createdAt: -1 });
149
151
  paymentSchema.index({ paymentStatus: 1 });
150
152
  paymentSchema.index({ token: 1 });
151
153
  paymentSchema.index({ gateway: 1 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "database-connector",
3
- "version": "2.2.7",
3
+ "version": "2.2.9",
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": {