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
strict: true for embedded documents #717
Comments
well that sucks |
An important note: You have to put child schema before the parent schema for strict mode to work properly with subdocuments. For this example, that means putting the Comments declaration before the BlogPost declaration. If you don't, strict mode will not work for subdocuments. Hopefully this will help people avoid the same problem I just ran into. Perhaps a note in the documentation would be helpful? In general, javascript doesn't care what order you declare functions and classes, so I found this behavior a little surprising. |
So it seems mongoose is setting strict mode to true for all but for some reason it is failing to enforce it when it comes to subdocuments. Even when I put child schema before parent schema it is not working for me, I guess I will post an issue with an example. |
@offminded please do |
I've noticed that
strict: true
doesn't work for embedded documents. I wasn't sure if this was by design or not.A quick example:
The text was updated successfully, but these errors were encountered: