Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Remove documentation for useNestedStrict #11313

Merged
merged 2 commits into from
Feb 7, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,6 @@ Valid options:
- [toJSON](#toJSON)
- [toObject](#toObject)
- [typeKey](#typeKey)
- [useNestedStrict](#useNestedStrict)
- [validateBeforeSave](#validateBeforeSave)
- [versionKey](#versionKey)
- [optimisticConcurrency](#optimisticConcurrency)
Expand Down Expand Up @@ -1158,42 +1157,6 @@ const schema = Schema({
});
```

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

Write operations like `update()`, `updateOne()`, `updateMany()`,
and `findOneAndUpdate()` only check the top-level
schema's strict mode setting.

```javascript
const childSchema = new Schema({}, { strict: false });
const parentSchema = new Schema({ child: childSchema }, { strict: 'throw' });
const Parent = mongoose.model('Parent', parentSchema);
Parent.update({}, { 'child.name': 'Luke Skywalker' }, (error) => {
// Error because parentSchema has `strict: throw`, even though
// `childSchema` has `strict: false`
});

const update = { 'child.name': 'Luke Skywalker' };
const opts = { strict: false };
Parent.update({}, update, opts, function(error) {
// This works because passing `strict: false` to `update()` overwrites
// the parent schema.
});
```

If you set `useNestedStrict` to true, mongoose will use the child schema's
`strict` option for casting updates.

```javascript
const childSchema = new Schema({}, { strict: false });
const parentSchema = new Schema({ child: childSchema },
{ strict: 'throw', useNestedStrict: true });
const Parent = mongoose.model('Parent', parentSchema);
Parent.update({}, { 'child.name': 'Luke Skywalker' }, error => {
// Works!
});
```

<h3 id="selectPopulatedPaths">
<a href="#selectPopulatedPaths">
option: selectPopulatedPaths
Expand Down