vasuzex 2.3.11 → 2.3.12

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.
@@ -859,14 +859,22 @@ export class Model extends GuruORMModel {
859
859
  if (this.timestamps && this.updatedAt) {
860
860
  if (!Object.prototype.hasOwnProperty.call(this, '_cachedUpdateFn')) {
861
861
  const modelClass = this;
862
- // query.update is EloquentBuilder.prototype.update a stable reference
863
- // captured once and reused for the lifetime of this model class.
864
- const protoUpdate = query.update;
862
+ // IMPORTANT: Do NOT capture `query.update` here. `query` is a Proxy, and
863
+ // accessing `.update` on a Proxy returns a new wrapper closure that hardcodes
864
+ // the specific builder instance (`target`) from that call. Caching that wrapper
865
+ // means all subsequent `.update()` calls would execute against the ORIGINAL
866
+ // builder's QueryBuilder (from the first call), ignoring the current query's
867
+ // WHERE clauses (e.g. the per-record `WHERE id = ?` clause would be lost).
868
+ //
869
+ // Instead, use `this.query.update(data)` directly. When _cachedUpdateFn is
870
+ // invoked, `this` is the current EloquentBuilder instance (set by the Proxy's
871
+ // get trap via `value.apply(target, args)`), so `this.query` is the correct
872
+ // underlying QueryBuilder with all accumulated WHERE clauses.
865
873
  this._cachedUpdateFn = async function timestampedUpdate(data) {
866
874
  if (data[modelClass.updatedAt] === undefined) {
867
875
  data[modelClass.updatedAt] = new Date();
868
876
  }
869
- return protoUpdate.call(this, data);
877
+ return this.query.update(data);
870
878
  };
871
879
  }
872
880
  query.update = this._cachedUpdateFn;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vasuzex",
3
- "version": "2.3.11",
3
+ "version": "2.3.12",
4
4
  "description": "Laravel-inspired framework for Node.js monorepos - V2 with optimized dependencies",
5
5
  "type": "module",
6
6
  "main": "./framework/index.js",
@@ -108,7 +108,7 @@
108
108
  "express-rate-limit": "^8.2.1",
109
109
  "firebase-admin": "^13.6.0",
110
110
  "fs-extra": "^11.3.2",
111
- "guruorm": "^2.1.23",
111
+ "guruorm": "^2.1.24",
112
112
  "helmet": "^8.1.0",
113
113
  "inquirer": "^9.3.8",
114
114
  "ip2location-nodejs": "^9.7.0",