title: Mongoose update 'cannot use the part (..) to traverse the element
body: <p>I have this really annoying issue where i can't update anything using mongoose. It's really frustrating to use, and the documentation is not helping at all.</p>
  
  <p>I have this schema:</p>
  
  <pre><code>var userSchema = mongoose.Schema({
  
      local            : {
          email        : String,
          password     : String,
      },
      devices : [{
        id : String,
        name : String
      }]
  });
  </code></pre>
  
  <p>And this is the code where i want to add a device to the array <code>devices</code> :</p>
  
  <pre><code>function updateDeviceList(user, deviceID, deviceName)
  {
    User.update({ 'local.email' : user}, 
    { $set: {'devices.id' : deviceID, 'devices.name' : deviceName}}, 
    function(err, response)
    {
      if(err)
      {
        console.log("Update device error", err);
      }
      else {
        console.log("Update device OK");
      }
    });
  }
  </code></pre>
  
  <p>At this point i get the error: 
  <code>errmsg: 'cannot use the part (devices of devices.id) to traverse the element ({devices: []})' }</code></p>
  
  <p>I didn't manage to find an explanation to why this is happening. I have to mention that the document (there is pretty much only one document in the database), is this one: </p>
  
  <pre><code>{
      "_id": {
          "$oid": "5585a196fe11b21100635c74"
      },
      "devices": [],
      "local": {
          "password": "$2a$10$7hXVHw7izcYlqbD6xe/te.0w2zucZ7lA007g9kXdoIMPhZhRyCIru",
          "email": "a@a.a"
      },
      "__v": 0
  }
  </code></pre>