You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -3311,7 +3328,7 @@ function prepareDiscriminatorCriteria(query) {
3311
3328
* - `maxTimeMS`: puts a time limit on the query - requires mongodb >= 2.6.0
3312
3329
* - `runValidators`: if true, runs [update validators](https://mongoosejs.com/docs/validation.html#update-validators) on this command. Update validators validate the update operation against the model's schema.
3313
3330
* - `setDefaultsOnInsert`: `true` by default. If `setDefaultsOnInsert` and `upsert` are true, mongoose will apply the [defaults](https://mongoosejs.com/docs/defaults.html) specified in the model's schema if a new document is created.
3314
-
* - `strictFilter`: bool - if true, throws an error if the filter is empty (`{}`). Defaults to false.
3331
+
* - `requireFilter`: bool - if true, throws an error if the filter is empty (`{}`). Defaults to false.
3315
3332
*
3316
3333
* #### Example:
3317
3334
*
@@ -3338,7 +3355,7 @@ function prepareDiscriminatorCriteria(query) {
3338
3355
* @param {Boolean} [options.translateAliases=null] If set to `true`, translates any schema-defined aliases in `filter`, `projection`, `update`, and `distinct`. Throws an error if there are any conflicts where both alias and raw property are defined on the same object.
3339
3356
* @param {Boolean} [options.overwriteDiscriminatorKey=false] Mongoose removes discriminator key updates from `update` by default, set `overwriteDiscriminatorKey` to `true` to allow updating the discriminator key
3340
3357
* @param {Boolean} [options.overwriteImmutable=false] Mongoose removes updated immutable properties from `update` by default (excluding $setOnInsert). Set `overwriteImmutable` to `true` to allow updating immutable properties using other update operators.
3341
-
* @param {Boolean} [options.strictFilter=false] If true, throws an error if the filter is empty (`{}`)
3358
+
* @param {Boolean} [options.requireFilter=false] If true, throws an error if the filter is empty (`{}`)
@@ -3507,6 +3522,7 @@ Query.prototype._findOneAndUpdate = async function _findOneAndUpdate() {
3507
3522
*
3508
3523
* - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
3509
3524
* - `maxTimeMS`: puts a time limit on the query - requires mongodb >= 2.6.0
3525
+
* - `requireFilter`: bool - if true, throws an error if the filter is empty (`{}`). Defaults to false.
3510
3526
*
3511
3527
* #### Example:
3512
3528
*
@@ -3519,6 +3535,7 @@ Query.prototype._findOneAndUpdate = async function _findOneAndUpdate() {
3519
3535
* @param {Object} [filter]
3520
3536
* @param {Object} [options]
3521
3537
* @param {Boolean} [options.includeResultMetadata] if true, returns the full [ModifyResult from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html) rather than just the document
3538
+
* @param {Boolean} [options.requireFilter=false] If true, throws an error if the filter is empty (`{}`)
3522
3539
* @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](https://mongoosejs.com/docs/transactions.html).
3523
3540
* @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
3524
3541
* @return {Query} this
@@ -3558,6 +3575,9 @@ Query.prototype._findOneAndDelete = async function _findOneAndDelete() {
3558
3575
this._applyTranslateAliases();
3559
3576
this._castConditions();
3560
3577
3578
+
// Check for empty/invalid filter with requireFilter option
@@ -3597,6 +3617,7 @@ Query.prototype._findOneAndDelete = async function _findOneAndDelete() {
3597
3617
* - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
3598
3618
* - `maxTimeMS`: puts a time limit on the query - requires mongodb >= 2.6.0
3599
3619
* - `includeResultMetadata`: if true, returns the full [ModifyResult from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.9/interfaces/ModifyResult.html) rather than just the document
3620
+
* - `requireFilter`: bool - if true, throws an error if the filter is empty (`{}`). Defaults to false.
3600
3621
*
3601
3622
* #### Example:
3602
3623
*
@@ -3619,6 +3640,7 @@ Query.prototype._findOneAndDelete = async function _findOneAndDelete() {
3619
3640
* @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set.
3620
3641
* @param {Boolean} [options.returnOriginal=null] An alias for the `new` option. `returnOriginal: false` is equivalent to `new: true`.
3621
3642
* @param {Boolean} [options.translateAliases=null] If set to `true`, translates any schema-defined aliases in `filter`, `projection`, `update`, and `distinct`. Throws an error if there are any conflicts where both alias and raw property are defined on the same object.
3643
+
* @param {Boolean} [options.requireFilter=false] If true, throws an error if the filter is empty (`{}`)
@@ -4126,6 +4155,7 @@ Query.prototype._replaceOne = async function _replaceOne() {
4126
4155
* @param {Boolean} [options.translateAliases=null] If set to `true`, translates any schema-defined aliases in `filter`, `projection`, `update`, and `distinct`. Throws an error if there are any conflicts where both alias and raw property are defined on the same object.
4127
4156
* @param {Boolean} [options.overwriteDiscriminatorKey=false] Mongoose removes discriminator key updates from `update` by default, set `overwriteDiscriminatorKey` to `true` to allow updating the discriminator key
4128
4157
* @param {Boolean} [options.overwriteImmutable=false] Mongoose removes updated immutable properties from `update` by default (excluding $setOnInsert). Set `overwriteImmutable` to `true` to allow updating immutable properties using other update operators.
4158
+
* @param {Boolean} [options.requireFilter=false] If true, throws an error if the filter is empty (`{}`)
* @param {Boolean} [options.translateAliases=null] If set to `true`, translates any schema-defined aliases in `filter`, `projection`, `update`, and `distinct`. Throws an error if there are any conflicts where both alias and raw property are defined on the same object.
4201
4231
* @param {Boolean} [options.overwriteDiscriminatorKey=false] Mongoose removes discriminator key updates from `update` by default, set `overwriteDiscriminatorKey` to `true` to allow updating the discriminator key
4202
4232
* @param {Boolean} [options.overwriteImmutable=false] Mongoose removes updated immutable properties from `update` by default (excluding $setOnInsert). Set `overwriteImmutable` to `true` to allow updating immutable properties using other update operators.
4233
+
* @param {Boolean} [options.requireFilter=false] If true, throws an error if the filter is empty (`{}`)
* @param {Object} [options.writeConcern=null] sets the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/) for replica sets. Overrides the [schema-level write concern](https://mongoosejs.com/docs/guide.html#writeConcern)
4267
4298
* @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Does nothing if schema-level timestamps are not set.
4268
4299
* @param {Boolean} [options.translateAliases=null] If set to `true`, translates any schema-defined aliases in `filter`, `projection`, `update`, and `distinct`. Throws an error if there are any conflicts where both alias and raw property are defined on the same object.
4300
+
* @param {Boolean} [options.requireFilter=false] If true, throws an error if the filter is empty (`{}`)
0 commit comments