When using a Map of Mixed (mongoose.Schema.Types.mixed) types in a subschema, a TypeError is thrown when trying to update or assign a value to a nested property of that mixed type using updateOne() or findOneAndUpdate(). #12530
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Prerequisites
Mongoose version
6.6.4
Node.js version
18.8.0
MongoDB version
4.2.20
Operating system
No response
Operating system version (i.e. 20.04, 11.3, 10)
No response
Issue
When using a Map of Mixed (mongoose.Schema.Types.mixed) types in a subSchema, a TypeError is thrown when trying to update or assign a value to a nested property of that mixed typo using updateOne() or findOneAndUpdate().
One field I have in a schema is a generic 'properties', that's a type Map of Schema.Types.Mixed.
When this 'properties' field is on a top-level schema, I can $set values in it without issue, including nested values:
However, when this 'properties' field is in a nested child schema, I'm seeing an error when trying to $set nested values within that properties.
The issue I'm seeing is:
I included a script that could reproduce the issue:
The parent schema includes one of these 'properties' fields and an instance of a child schema which in turn also includes one of these 'properties' fields.
Is this a bug, or is there a better way I should be setting up this schema and making calls to update values within that schema, including that properties value?
Thanks in advance!
The text was updated successfully, but these errors were encountered: