database-connector 2.4.4 → 2.4.5

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
@@ -29,6 +29,10 @@
29
29
  - Updated Swagger documentation to reflect new field
30
30
 
31
31
  - **Subscription Model**: Added multiple new fields and improvements
32
+ - **BREAKING CHANGE**: Changed `storeId` to `sellerId` - now references User (seller) instead of Store
33
+ - Updated all occurrences in main schema, subscriptionsHistory, and upcomingSubscriptions
34
+ - Updated indexes to use `sellerId` instead of `storeId`
35
+ - Updated history snapshot builder to track `sellerId`
32
36
  - `planTypeId`: ObjectId reference to PlanType model
33
37
  - `numberOfStores`: Number (default: 1, minimum: 1) - tracks number of stores in subscription
34
38
  - `billingAddress`: Mixed object for billing address (Adresse de facturation)
@@ -3,7 +3,7 @@ const mongoose = require('mongoose');
3
3
  const buildSubscriptionHistorySnapshot = (subscriptionDoc) => ({
4
4
  subscriptionId: subscriptionDoc._id,
5
5
  paymentManagerId: subscriptionDoc.paymentManagerId,
6
- storeId: subscriptionDoc.storeId,
6
+ sellerId: subscriptionDoc.sellerId,
7
7
  planId: subscriptionDoc.planId,
8
8
  planTypeId: subscriptionDoc.planTypeId,
9
9
  subscriptionOfferId: subscriptionDoc.subscriptionOfferId,
@@ -53,7 +53,7 @@ const deleteSubscriptionHistories = async (subscriptionId) => {
53
53
  * Subscription:
54
54
  * type: object
55
55
  * required:
56
- * - storeId
56
+ * - sellerId
57
57
  * - paymentAmount
58
58
  * - startDate
59
59
  * - endDate
@@ -64,9 +64,9 @@ const deleteSubscriptionHistories = async (subscriptionId) => {
64
64
  * paymentManagerId:
65
65
  * type: string
66
66
  * description: Reference to the payment manager
67
- * storeId:
67
+ * sellerId:
68
68
  * type: string
69
- * description: Reference to the store
69
+ * description: Reference to the seller (user)
70
70
  * planId:
71
71
  * type: string
72
72
  * description: Reference to the plan
@@ -134,7 +134,7 @@ const deleteSubscriptionHistories = async (subscriptionId) => {
134
134
  * $ref: '#/components/schemas/SubscriptionHistory'
135
135
  * example:
136
136
  * id: "507f1f77bcf86cd799439011"
137
- * storeId: "507f1f77bcf86cd799439012"
137
+ * sellerId: "507f1f77bcf86cd799439012"
138
138
  * planId: "507f1f77bcf86cd799439013"
139
139
  * paymentAmount: 99.99
140
140
  * paymentIntentId: "507f1f77bcf86cd799439099"
@@ -149,10 +149,10 @@ const subscriptionSchema = new mongoose.Schema(
149
149
  required: false,
150
150
  ref: 'User',
151
151
  },
152
- storeId: {
152
+ sellerId: {
153
153
  type: mongoose.Schema.Types.ObjectId,
154
154
  required: true,
155
- ref: 'Store',
155
+ ref: 'User',
156
156
  },
157
157
  planId: {
158
158
  type: mongoose.Schema.Types.ObjectId,
@@ -240,10 +240,10 @@ const subscriptionSchema = new mongoose.Schema(
240
240
  required: false,
241
241
  ref: 'User',
242
242
  },
243
- storeId: {
243
+ sellerId: {
244
244
  type: mongoose.Schema.Types.ObjectId,
245
245
  required: false,
246
- ref: 'Store',
246
+ ref: 'User',
247
247
  },
248
248
  planId: {
249
249
  type: mongoose.Schema.Types.ObjectId,
@@ -324,10 +324,10 @@ const subscriptionSchema = new mongoose.Schema(
324
324
  required: false,
325
325
  ref: 'User',
326
326
  },
327
- storeId: {
327
+ sellerId: {
328
328
  type: mongoose.Schema.Types.ObjectId,
329
329
  required: false,
330
- ref: 'Store',
330
+ ref: 'User',
331
331
  },
332
332
  planId: {
333
333
  type: mongoose.Schema.Types.ObjectId,
@@ -443,14 +443,14 @@ subscriptionSchema.pre('deleteOne', { document: false, query: true }, async func
443
443
  });
444
444
 
445
445
  // Indexes for performance optimization
446
- subscriptionSchema.index({ storeId: 1 });
446
+ subscriptionSchema.index({ sellerId: 1 });
447
447
  subscriptionSchema.index({ status: 1 });
448
448
  subscriptionSchema.index({ endDate: 1 });
449
449
  subscriptionSchema.index({ startDate: 1 });
450
450
  subscriptionSchema.index({ planId: 1 });
451
451
  subscriptionSchema.index({ planTypeId: 1 });
452
452
  subscriptionSchema.index({ paymentManagerId: 1 });
453
- subscriptionSchema.index({ storeId: 1, status: 1 });
453
+ subscriptionSchema.index({ sellerId: 1, status: 1 });
454
454
  subscriptionSchema.index({ status: 1, endDate: 1 });
455
455
 
456
456
  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.4",
3
+ "version": "2.4.5",
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": {