mongoose 7.8.11 → 7.8.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.
package/lib/query.js CHANGED
@@ -2625,11 +2625,7 @@ Query.prototype.findOne = function(conditions, projection, options) {
2625
2625
  */
2626
2626
 
2627
2627
  Query.prototype._count = async function _count() {
2628
- try {
2629
- this.cast(this.model);
2630
- } catch (err) {
2631
- this.error(err);
2632
- }
2628
+ this._castConditions();
2633
2629
 
2634
2630
  if (this.error()) {
2635
2631
  throw this.error();
@@ -2655,11 +2651,7 @@ Query.prototype._count = async function _count() {
2655
2651
  */
2656
2652
 
2657
2653
  Query.prototype._countDocuments = async function _countDocuments() {
2658
- try {
2659
- this.cast(this.model);
2660
- } catch (err) {
2661
- this.error(err);
2662
- }
2654
+ this._castConditions();
2663
2655
 
2664
2656
  if (this.error()) {
2665
2657
  throw this.error();
@@ -5057,11 +5049,17 @@ Query.prototype.cursor = function cursor(opts) {
5057
5049
  }
5058
5050
 
5059
5051
  try {
5060
- this.cast(this.model);
5052
+ this._castConditions();
5061
5053
  } catch (err) {
5054
+ // `_castConditions()` reports cast errors on the query, but `sanitizeFilter`
5055
+ // throws for filters it refuses outright, like `$where`.
5062
5056
  return (new QueryCursor(this))._markError(err);
5063
5057
  }
5064
5058
 
5059
+ if (this.error()) {
5060
+ return (new QueryCursor(this))._markError(this.error());
5061
+ }
5062
+
5065
5063
  return new QueryCursor(this);
5066
5064
  };
5067
5065
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mongoose",
3
3
  "description": "Mongoose MongoDB ODM",
4
- "version": "7.8.11",
4
+ "version": "7.8.12",
5
5
  "author": "Guillermo Rauch <guillermo@learnboost.com>",
6
6
  "keywords": [
7
7
  "mongodb",