mongoose 8.24.2 → 8.24.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.
Files changed (2) hide show
  1. package/lib/query.js +8 -7
  2. package/package.json +1 -1
package/lib/query.js CHANGED
@@ -2787,12 +2787,7 @@ Query.prototype.findOne = function(conditions, projection, options) {
2787
2787
 
2788
2788
  Query.prototype._countDocuments = async function _countDocuments() {
2789
2789
  this._applyTranslateAliases();
2790
-
2791
- try {
2792
- this.cast(this.model);
2793
- } catch (err) {
2794
- this.error(err);
2795
- }
2790
+ this._castConditions();
2796
2791
 
2797
2792
  if (this.error()) {
2798
2793
  throw this.error();
@@ -5204,11 +5199,17 @@ Query.prototype.cursor = function cursor(opts) {
5204
5199
  }
5205
5200
 
5206
5201
  try {
5207
- this.cast(this.model);
5202
+ this._castConditions();
5208
5203
  } catch (err) {
5204
+ // `_castConditions()` reports cast errors on the query, but `sanitizeFilter`
5205
+ // throws for filters it refuses outright, like `$where`.
5209
5206
  return (new QueryCursor(this))._markError(err);
5210
5207
  }
5211
5208
 
5209
+ if (this.error()) {
5210
+ return (new QueryCursor(this))._markError(this.error());
5211
+ }
5212
+
5212
5213
  return new QueryCursor(this);
5213
5214
  };
5214
5215
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mongoose",
3
3
  "description": "Mongoose MongoDB ODM",
4
- "version": "8.24.2",
4
+ "version": "8.24.3",
5
5
  "author": "Guillermo Rauch <guillermo@learnboost.com>",
6
6
  "keywords": [
7
7
  "mongodb",