These are chat archives for Automattic/mongoose

Feb 2016
Jonathan Gros-Dubois
Feb 25 2016 13:15
Hi all. I have a problem: I have a document/model with a property which holds an array of nested objects (Let's call the main model MainModel and the array is stored in a property nestedObjectsArray). These nested objects do not have a schema. Now I want to add a new boolean property (let's call this property myNestedProperty) to one of these nested objects (which is inside the array). I can find the nested object without any problem, but for some reason, mongoose won't actually let me update the nested object to add the myNestedProperty property. I tried calling the save() method on the instance of the MainModel object and I also tried calling MainModel.collection.update({_id: myMainModelObjectInstance._id}, myMainModelObjectInstance, callback) - No matter what I try, it doesn't actually update the object. Also the callback gets executed successfully without any errors. If I try to do the same thing using the plain mongodb client driver, everything works fine.
Anyone has experience working with nested objects like this?
What could cause this problem?
Luis Miguel Díaz Abril
Feb 25 2016 19:04
This message was deleted
Jonathan Gros-Dubois
Feb 25 2016 23:38
Defining the schema on the nested documents seems to solve the problem