mongoose 7.8.2 → 7.8.3

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.
@@ -250,7 +250,7 @@ function numDocs(v) {
250
250
 
251
251
  function valueFilter(val, assignmentOpts, populateOptions, allIds) {
252
252
  const userSpecifiedTransform = typeof populateOptions.transform === 'function';
253
- const transform = userSpecifiedTransform ? populateOptions.transform : noop;
253
+ const transform = userSpecifiedTransform ? populateOptions.transform : v => v;
254
254
  if (Array.isArray(val)) {
255
255
  // find logic
256
256
  const ret = [];
@@ -342,7 +342,3 @@ function isPopulatedObject(obj) {
342
342
  obj.$__ != null ||
343
343
  leanPopulateMap.has(obj);
344
344
  }
345
-
346
- function noop(v) {
347
- return v;
348
- }
@@ -184,6 +184,15 @@ module.exports = function getModelsMapForPopulate(model, docs, options) {
184
184
  if (hasMatchFunction) {
185
185
  match = match.call(doc, doc);
186
186
  }
187
+ if (Array.isArray(match)) {
188
+ for (const item of match) {
189
+ if (item != null && item.$where) {
190
+ throw new MongooseError('Cannot use $where filter with populate() match');
191
+ }
192
+ }
193
+ } else if (match != null && match.$where != null) {
194
+ throw new MongooseError('Cannot use $where filter with populate() match');
195
+ }
187
196
  data.match = match;
188
197
  data.hasMatchFunction = hasMatchFunction;
189
198
  data.isRefPath = isRefPath;
@@ -461,6 +470,16 @@ function _virtualPopulate(model, docs, options, _virtualRes) {
461
470
  data.match = match;
462
471
  data.hasMatchFunction = hasMatchFunction;
463
472
 
473
+ if (Array.isArray(match)) {
474
+ for (const item of match) {
475
+ if (item != null && item.$where) {
476
+ throw new MongooseError('Cannot use $where filter with populate() match');
477
+ }
478
+ }
479
+ } else if (match != null && match.$where != null) {
480
+ throw new MongooseError('Cannot use $where filter with populate() match');
481
+ }
482
+
464
483
  // Get local fields
465
484
  const ret = _getLocalFieldValues(doc, localField, model, options, virtual);
466
485
 
package/lib/query.js CHANGED
@@ -4431,10 +4431,10 @@ Query.prototype.exec = async function exec(op) {
4431
4431
  str = str.slice(0, 60) + '...';
4432
4432
  }
4433
4433
  const err = new MongooseError('Query was already executed: ' + str);
4434
- err.originalStack = this._executionStack.stack;
4434
+ err.originalStack = this._executionStack;
4435
4435
  throw err;
4436
4436
  } else {
4437
- this._executionStack = new Error();
4437
+ this._executionStack = new Error().stack;
4438
4438
  }
4439
4439
 
4440
4440
  await _executePreExecHooks(this);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mongoose",
3
3
  "description": "Mongoose MongoDB ODM",
4
- "version": "7.8.2",
4
+ "version": "7.8.3",
5
5
  "author": "Guillermo Rauch <guillermo@learnboost.com>",
6
6
  "keywords": [
7
7
  "mongodb",
@@ -58,7 +58,7 @@
58
58
  "mkdirp": "^3.0.1",
59
59
  "mocha": "10.2.0",
60
60
  "moment": "2.x",
61
- "mongodb-memory-server": "9.2.0",
61
+ "mongodb-memory-server": "9.5.0",
62
62
  "ncp": "^2.0.0",
63
63
  "nyc": "15.1.0",
64
64
  "pug": "3.0.2",