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

Update guide.md #11135

Merged
merged 1 commit into from
Dec 24, 2021
Merged

Update guide.md #11135

merged 1 commit into from
Dec 24, 2021

Conversation

MontgomeryWatts
Copy link
Contributor

Update example for strictQuery to indicate it will not remove fields not in schema when set to false.

Summary

The documentation currently states setting strictQuery to false will strip out fields in the filter that are not part of the Schema. This is the opposite of what setting strictQuery to false does.

Examples

const mySchema = new Schema({ field: Number }, {
  strict: true,
  strictQuery: true
});
const MyModel = mongoose.model('Test', mySchema);
// Mongoose will strip out `notInSchema: 1` because `strictQuery` is true
MyModel.find({ notInSchema: 1 });
const mySchema = new Schema({ field: Number }, {
  strict: true,
  strictQuery: false // Turn off strict mode for query filters
});
const MyModel = mongoose.model('Test', mySchema);
// Mongoose will not strip out `notInSchema: 1` because `strictQuery` is false
MyModel.find({ notInSchema: 1 });

Update example for `strictQuery` to indicate it will *not* remove fields not in schema when set to `false`.
Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@vkarpov15 vkarpov15 added the docs This issue is due to a mistake or omission in the mongoosejs.com documentation label Dec 24, 2021
@vkarpov15 vkarpov15 added this to the 6.1.4 milestone Dec 24, 2021
@vkarpov15 vkarpov15 merged commit 0c7023d into Automattic:master Dec 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants