title: Setting value of an array element in Mongoose using index
body: <p>I am trying to update an element at a specific index in a mongodb array with mongoose. </p>
  
  <pre><code>db.Comment.findOneAndUpdate(
      {_id: '51fc9c329e87bf0000000001'},
      {$set: { 'body.0' : 'Comment Body'}}).exec(...);
  </code></pre>
  
  <p>This works fine, however, when I use a variable to set the index it doesn't seem to work. Does anyone know why?</p>
  
  <pre><code>    var indexString = "'body.0'";
  
      db.Comment.findOneAndUpdate(
          {_id: '51fc9c329e87bf0000000001'},
          {$set: { indexString : 'Comment Body'}}).exec(...);
  </code></pre>
  
  <p>And how would I get this working so that I can set the index as needed?</p>