Model.findOneAndUpdate() is updating nested fields with 'strict:false' #13434
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Discussed in #13432
Originally posted by amitpriyankar May 24, 2023
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
The text was updated successfully, but these errors were encountered: