database-connector 2.4.6 → 2.4.7

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/CHANGELOG.md CHANGED
@@ -40,11 +40,12 @@
40
40
  - All history tracking done via embedded subscriptionsHistory and upcomingSubscriptions arrays
41
41
  - `planTypeId`: ObjectId reference to PlanType model
42
42
  - `numberOfStores`: Number (default: 1, minimum: 1) - tracks number of stores in subscription
43
+ - `stores`: Array of ObjectIds referencing Store - tracks which specific stores are included in this subscription
43
44
  - `billingAddress`: Mixed object for billing address (Adresse de facturation)
44
45
  - `invoiceRecipient`: Object with type (Person/Company enum) and name fields (Facture au nom de)
45
46
  - `invoiceLink`: String (nullable, default: null) - link to the invoice document
46
47
  - Updated `subscriptionsHistory` and `upcomingSubscriptions` arrays to include complete subscription snapshots
47
- - Both now include all fields: storeId, planId, planTypeId, paymentTypeId, paymentIntentId, reductionOfferId, numberOfStores, billingAddress, invoiceRecipient, invoiceLink
48
+ - Both now include all fields: storeId, planId, planTypeId, paymentTypeId, paymentIntentId, reductionOfferId, numberOfStores, stores, billingAddress, invoiceRecipient, invoiceLink
48
49
  - Makes history tracking consistent and comprehensive
49
50
  - Added `planTypeId` index for performance optimization
50
51
  - Updated history snapshot builder to include all new fields including invoiceLink
@@ -224,7 +225,8 @@ After comprehensive analysis of model usage across all microservices (AuthServic
224
225
  - `paymentManagerId`: For payment manager tracking
225
226
  - `storeId, status` (compound): For store subscription status
226
227
  - `status, endDate` (compound): For active subscription expiration monitoring
227
- - **Justification:** SubscriptionService queries subscriptions by store, status, and expiration dates. Compound indexes optimize active subscription monitoring and store subscription management.
228
+ - `stores`: For queries filtering by specific stores in the subscription
229
+ - **Justification:** SubscriptionService queries subscriptions by store, status, and expiration dates. Compound indexes optimize active subscription monitoring and store subscription management. The stores index enables efficient queries to find subscriptions containing specific stores.
228
230
 
229
231
  **13. UserAction Model** (`UserAction.js`)
230
232
  - **Indexes Added:**
@@ -11,6 +11,7 @@ const buildSubscriptionHistorySnapshot = (subscriptionDoc) => ({
11
11
  paymentIntentId: subscriptionDoc.paymentIntentId,
12
12
  reductionOfferId: subscriptionDoc.reductionOfferId,
13
13
  numberOfStores: subscriptionDoc.numberOfStores,
14
+ stores: subscriptionDoc.stores,
14
15
  billingAddress: subscriptionDoc.billingAddress,
15
16
  invoiceRecipient: subscriptionDoc.invoiceRecipient,
16
17
  invoiceLink: subscriptionDoc.invoiceLink,
@@ -65,6 +66,11 @@ const recordSubscriptionHistory = async (subscriptionDoc) => {
65
66
  * type: number
66
67
  * default: 1
67
68
  * description: Number of stores in this subscription
69
+ * stores:
70
+ * type: array
71
+ * items:
72
+ * type: string
73
+ * description: Array of store IDs included in this subscription
68
74
  * billingAddress:
69
75
  * type: object
70
76
  * description: Billing address for the subscription
@@ -164,6 +170,15 @@ const subscriptionSchema = new mongoose.Schema(
164
170
  default: 1,
165
171
  min: 1,
166
172
  },
173
+ stores: {
174
+ type: [
175
+ {
176
+ type: mongoose.Schema.Types.ObjectId,
177
+ ref: 'Store',
178
+ },
179
+ ],
180
+ default: [],
181
+ },
167
182
  billingAddress: {
168
183
  type: mongoose.Schema.Types.Mixed,
169
184
  required: false,
@@ -267,6 +282,15 @@ const subscriptionSchema = new mongoose.Schema(
267
282
  type: Number,
268
283
  default: 1,
269
284
  },
285
+ stores: {
286
+ type: [
287
+ {
288
+ type: mongoose.Schema.Types.ObjectId,
289
+ ref: 'Store',
290
+ },
291
+ ],
292
+ default: [],
293
+ },
270
294
  billingAddress: {
271
295
  type: mongoose.Schema.Types.Mixed,
272
296
  required: false,
@@ -351,6 +375,15 @@ const subscriptionSchema = new mongoose.Schema(
351
375
  type: Number,
352
376
  default: 1,
353
377
  },
378
+ stores: {
379
+ type: [
380
+ {
381
+ type: mongoose.Schema.Types.ObjectId,
382
+ ref: 'Store',
383
+ },
384
+ ],
385
+ default: [],
386
+ },
354
387
  billingAddress: {
355
388
  type: mongoose.Schema.Types.Mixed,
356
389
  required: false,
@@ -416,5 +449,6 @@ subscriptionSchema.index({ planTypeId: 1 });
416
449
  subscriptionSchema.index({ paymentManagerId: 1 });
417
450
  subscriptionSchema.index({ sellerId: 1, status: 1 });
418
451
  subscriptionSchema.index({ status: 1, endDate: 1 });
452
+ subscriptionSchema.index({ stores: 1 });
419
453
 
420
454
  module.exports = mongoose.model('Subscription', subscriptionSchema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "database-connector",
3
- "version": "2.4.6",
3
+ "version": "2.4.7",
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": {