Skip to content

Commit

Permalink
docs(guide): remove strictQuery option from schemas re: #10605
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Aug 25, 2021
1 parent 9b61ff1 commit 0a38c79
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ Valid options:
- [writeConcern](#writeConcern)
- [shardKey](#shardKey)
- [strict](#strict)
- [strictQuery](#strictQuery)
- [toJSON](#toJSON)
- [toObject](#toObject)
- [typeKey](#typeKey)
Expand Down Expand Up @@ -756,41 +755,6 @@ thing.iAmNotInTheSchema = true;
thing.save(); // iAmNotInTheSchema is never saved to the db
```

<h3 id="strictQuery"><a href="#strictQuery">option: strictQuery</a></h3>

For backwards compatibility, the `strict` option does **not** apply to
the `filter` parameter for queries.

```javascript
const mySchema = new Schema({ field: Number }, { strict: true });
const MyModel = mongoose.model('Test', mySchema);

// Mongoose will **not** filter out `notInSchema: 1`, despite `strict: true`
MyModel.find({ notInSchema: 1 });
```

The `strict` option does apply to updates.

```javascript
// Mongoose will strip out `notInSchema` from the update if `strict` is
// not `false`
MyModel.updateMany({}, { $set: { notInSchema: 1 } });
```

Mongoose has a separate `strictQuery` option to toggle strict mode for
the `filter` parameter to queries.

```javascript
const mySchema = new Schema({ field: Number }, {
strict: true,
strictQuery: true // Turn on strict mode for query filters
});
const MyModel = mongoose.model('Test', mySchema);

// Mongoose will strip out `notInSchema: 1` because `strictQuery` is `true`
MyModel.find({ notInSchema: 1 });
```

<h3 id="toJSON"><a href="#toJSON">option: toJSON</a></h3>

Exactly the same as the [toObject](#toObject) option but only applies when
Expand Down

0 comments on commit 0a38c79

Please sign in to comment.