Schema.type.Mixed and deep modification does not update document
See original GitHub issueWhen I try to update a deep nested field, the query is well sent to MongoDB but when I do a find on this doc, the field is not updated.
Example
var DtSchema = mongoose.Schema({
nested : Schema.type.mixed
});
var Dt = mongoose.model('Dt', DtSchema)
var test = new Dt({nested : { a : 'test', b : { c : { d : null } } } });
test.save(function(err, _test) {
_test.nested.b.c.d = 'Hello !';
_test.save(function(err, _test) {
// _test is okay, the field nested.b.c.d is updated
Dt.findOne({_id : _test._id}, function(err, doc) {
// Here The doc has not the nested.b.c.d field updated
});
})
});
Issue Analytics
- State:
- Created 10 years ago
- Comments:16
Top Results From Across the Web
How do I update a [Schema.Types.Mixed]? - Stack Overflow
I want to add another field "youtube". How do I write updateOne query such that it upserts this new field in profiles? And...
Read more >Manage Schemas for Topics in Control Center
To learn more, see Schema References in the schema formats developer documentation. View, edit, or delete schema references for a topic. Existing schema...
Read more >Mongoose v6.8.1: Schema
Using this exposed access to the Mixed SchemaType, we can use them in our schema. const Mixed = mongoose.Schema.Types.Mixed; new mongoose.
Read more >Specifying a schema | BigQuery - Google Cloud
After loading data or creating an empty table, you can modify the table's ... in your schema file by using the Google Cloud...
Read more >MongoDB | NestJS - A progressive Node.js framework
Hint Note you can also generate a raw schema definition using the DefinitionsFactory class (from the nestjs/mongoose ). This allows you to manually...
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 FreeTop 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
Top GitHub Comments
Did you guys try using markModified()? Mixed types won’t save updates unless you tell Mongoose something has changed
If you do this, it will work.
var nested = JSON.parse(JSON.stringify(_test.nested)); //now changed the nested object. nested.a = “new value” _test.nested = nested; _test.save();