title: mongoose updating a specific field in a nested document at a 3rd level
body: <p>mongoose scheme:</p>
  
  <pre><code>var restsSchema = new Schema({
      name: String,
      menu: mongoose.Schema.Types.Mixed
  });
  </code></pre>
  
  <p>simplfied document:</p>
  
  <pre><code>{
      name: "Dominos Pizza",
      menu:{
           "1":{
                id: 1,
                name: "Plain Pizza",
                soldCounter: 0
             },
           "2":{
                id: 2,
                name: "Pizza with vegetables",
                soldCounter: 0
              }
       }
  }
  </code></pre>
  
  <p>I'm trying to update the soldCounter when given a single/array of "menu items" (such as "1" or "2" objects in the above document) as followed:</p>
  
  <pre><code>function(course, rest){
      rest.markModified("menu.1");
      db.model('rests').update({_id: rest._id},{$inc:  {"menu.1.soldCounter":1}});
  }
  </code></pre>
  
  <p>once this will work i obviously will want to make it more generic, something like: (this syntax is not working but demonstrate my needs)</p>
  
  <pre><code>function(course, rest){
      rest.markModified("menu." + course.id);
      db.model('rests').update({_id: rest._id},{$inc:{"menu.+"course.id"+.soldCounter":1}});
  }
  </code></pre>
  
  <p>any one can help with this one?</p>
  
  <p>I looked for an answer but couldn't find nothing regarding the 3rd level.</p>
  
  <p><strong>UPDATE:</strong>
  Added id to the ducument's subDocument</p>