title: Mongoose/MongoDB dynamic object attribute name and update
body: <p>I'm trying to do something tricky but I'm not sure if that's the way to go.
  Here it is :</p>
  <p>I have an user with object dispos. Dispos contains arrays of months, so can be</p>
  <pre><code>user.dispos: {&quot;02-2015&quot; : [], &quot;05-2015&quot; : [] }
  </code></pre>
  <p>Now, I want to do a dynamic update of the specific month,
  for example I want to only update the user.dispos[&quot;02-2015&quot;] field and not replace the whole dispos object, letting the [&quot;05-2015&quot;] remaining.
  For now I tried :</p>
  <pre><code>User.update({ _id:  req.body.id }, 
  { $set: { dispos[&quot;02-2015&quot;]: disposOf-02-2015} }, function(error){
     if (error) return res.send(500, err);
     return res.send(204) });
  </code></pre>
  <p>It doesn't work, but you get what I mean... I want to update dispos at a certain position, not replacing the whole property.
  Thanks for your help.</p>
  <h1>edit</h1>
  <p>It's nearly there by using the dot notation and wrapping the property name in quotes. I'm using a variable to set the month-year of dispos. With <code>$set: { &quot;dispos.monthYear&quot;: dispos }</code> I get <code>dispos : { &quot;monthYear&quot; : { &quot;06-2015 : [] ...} }</code>. Well, I just dont need this &quot;monthYear&quot; level which should be the dynamic mont-year name. In this case monthYear = &quot;06-2015&quot; so I would like to get <code>dispos : { &quot;06-2015&quot;: []...}</code> which doesn't erase my other <code>dispos {&quot;07-2015&quot;}</code></p>