title: MongoDB and dynamic query building with $push statement with node.js
body: <p>I'm creating an application where I need to keep version of each field in database when update is performed. So I figured that I would use statement like this to accomplish it.</p>
  
  <pre><code> collection.update({ _id: id },
              {
                  $push: { placeholder : { $each: [{ data: keyValue, timeStamp: date, editor: editorID}] } }
              },  
  </code></pre>
  
  <p>The placeholder is a field which might be different each time depending which field I'm updating in the table.</p>
  
  <pre><code>var key = req.body.key;
  var keyValue = req.body.keyValue;
  var editorID = req.body.editor;
  var date = new Date();
  </code></pre>
  
  <p>The above variables are initialized  based on the form submitted and the <strong>key</strong> is the name of the database filed which I would like to use instead of placeholder. </p>
  
  <p>How can I make the placeholder to represent database field name passed from the form?</p>