database-connector 2.5.13 → 2.5.14

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.
@@ -506,6 +506,19 @@ subscriptionSchema.post('updateOne', async function () {
506
506
  }
507
507
  });
508
508
 
509
+ subscriptionSchema.post('findByIdAndUpdate', async function () {
510
+ const options = this.getOptions ? this.getOptions() : this.options;
511
+ if (options?.skipHistory || options?.$locals?.skipHistory || this?.$locals?.skipHistory) return;
512
+
513
+ // Record history from the OLD document (captured in pre hook)
514
+ if (this._oldDoc) {
515
+ const updatedDoc = await this.model.findOne(this.getQuery());
516
+ if (updatedDoc) {
517
+ await recordSubscriptionHistory(this._oldDoc, updatedDoc);
518
+ }
519
+ }
520
+ });
521
+
509
522
  // Indexes for performance optimization
510
523
  subscriptionSchema.index({ sellerId: 1 });
511
524
  subscriptionSchema.index({ status: 1 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "database-connector",
3
- "version": "2.5.13",
3
+ "version": "2.5.14",
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": {