Model.update with overwrite:true throws an error from versions 4.1.10 to 4.4.11
See original GitHub issueIt seems there has been a regression issue. Now Model.findByIdAndUpdate(id, obj, { overwrite: true })
throws an error when updating properties that are array of objects.
The document sample I’m using is the following:
var res = {
user: "John"
resources: [{
foo: 1
}, {
bar: 2
}]
}
Then Model.findByIdAndUpdate(doc._id, res, { overwrite: true })
throws:
"MongoError: exception: Invalid modifier specified: resources"
This is happening from versions 4.1.11 to the latest release (4.4.11).
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:8
Top Results From Across the Web
[WT-8395] Inconsistent data after upgrade from 4.4.3 and 4.4.4 ...
ISSUE DESCRIPTION AND IMPACT. This issue causes incorrect checkpoint metadata to sometimes be recorded by MongoDB versions 4.4.3 and 4.4.4.
Read more >api/node_modules/mongoose/History.md - GitLab
fix(schema): update clone method to include indexes #5268 ... fix(schema): throw error if you use prototype as a schema path #4746 ...
Read more >Alibaba Cloud
and an updated version of this document will be released through Alibaba ... 2.1.4.4.11. ... 4.1.10. OpenAPI. 4.1.10.1. Query PMML models. 4.1.10.2.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
traced this issue down to the root of the problem.
overwrite
breaks if you use thetimestamps
option for a Schema.Example
Result
This error still happens if the
overwrite
,upsert
andsetDefaultsOnInsert
options are present at.update()
options, but only if a property which has a default is not in the update object:Example
NOTICE: The result ist the same if you swap the second search criterion against
{ name: 'a' }
(so no upsert but a update should be performed).Result