database-connector 2.2.8 → 2.2.10

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/Offer.js CHANGED
@@ -58,6 +58,16 @@ const mongoose = require('mongoose');
58
58
  * type: string
59
59
  * enum: [percentage, amount]
60
60
  * description: Type of discount
61
+ * type:
62
+ * type: string
63
+ * enum: [followers, all, specific]
64
+ * default: all
65
+ * description: Who can see this offer
66
+ * userIds:
67
+ * type: array
68
+ * items:
69
+ * type: string
70
+ * description: Array of user IDs (used when type is 'specific')
61
71
  * createdAt:
62
72
  * type: string
63
73
  * format: date-time
@@ -135,6 +145,16 @@ const OfferSchema = new mongoose.Schema(
135
145
  required: true,
136
146
  enum: ['percentage', 'amount'],
137
147
  },
148
+ type: {
149
+ type: String,
150
+ default: 'all',
151
+ enum: ['followers', 'all', 'specific'],
152
+ },
153
+ userIds: {
154
+ type: [mongoose.Schema.Types.ObjectId],
155
+ ref: 'User',
156
+ default: [],
157
+ },
138
158
  },
139
159
  {
140
160
  timestamps: true,
@@ -154,5 +174,7 @@ OfferSchema.index({ offerStatus: 1 });
154
174
  OfferSchema.index({ offerExpiration: 1 });
155
175
  OfferSchema.index({ createdAt: -1 });
156
176
  OfferSchema.index({ offerDeleted: 1 });
177
+ OfferSchema.index({ type: 1 });
178
+ OfferSchema.index({ userIds: 1 });
157
179
 
158
180
  module.exports = mongoose.model('Offer', OfferSchema);
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "database-connector",
3
- "version": "2.2.8",
3
+ "version": "2.2.10",
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": {