Model.findOneAndUpdate() is updating nested fields with 'strict:false' #13432
Unanswered
amitpriyankar
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have observed an unusual behavior when using
Model.findOneAndUpdate
with a collection that has a flexible schema (strict: false). When I attempt to insert a document that includes a key containing a dot (.), the behavior differs based on whether I define the type of the key in the schema. If I specify the type, the key is treated as a regular string. However, if I don't specify the type, nested fields are created in the document.Please refer the following code:
I check the doc but didn't find anything which explains this behavior. Could someone please help?
mongoose: v7.1.1
MongoDB Server: 4.0
Beta Was this translation helpful? Give feedback.
All reactions