title: MongoDB Node JS - to delete an entry from an object inside a document object
body: <p>I'm trying to create a command in Node JS using native mongodb driver, to remove the key value pair from an object which is inside the document object.</p>
  
  <p>I have a mongoDB collection in the following format:</p>
  
  <pre><code>    {
      "name" : "PrakashPM"
      "data" : {
                 "Jan-2017" : "2,3,1",
                 "Dec-2016" : "1,2,0",
                 "Nov-2016" : "9,9,9"
               }
      },
      {
      "name" : "Valavan"
      "data" : {
                 "Jan-2017" : "1,1,1",
                 "Dec-2016" : "3,3,3",
                 "Nov-2016" : "9,9,9"
               }
      }
  </code></pre>
  
  <blockquote>
    <p>My target is to remove "Dec-2016" : "1,2,0" which is inside "name" :
    "PrakashPM"</p>
  </blockquote>
  
  <p>My Code:</p>
  
  <pre><code>var mongoName = 'PrakashPM';
  var mongoDate = "'data'.'Dec-2016'";
  // TRIALS
  // var mongoDate = "data.'Dec-2016'";
  // var mongoDate = "data.Dec-2016";
  
  
  var mongoVal = "'1,2,0'";
  // TRIALS
  // var mongoVal = "1,2,0";
  
  
  mycollection.update( { name: mongoName },
  { $unset: {mongoDate : mongoVal} }
  );
  </code></pre>
  
  <p>NOTE: I'm doing the above operations inside a PUT request function.</p>
  
  <p>I tried many possible ways (TRIALS) for the input values (mongoDate, mongoVal) but I'm not able to achieve the result below.</p>
  
  <p>Also, is it possible to remove the key value pair entry, just by using the key? (i.e. in this case {$unset: {mongoDate}} or something like that)</p>
  
  <p>EXPECTED RESULT:</p>
  
  <pre><code>    {
      "name" : "PrakashPM"
      "data" : {
                 "Jan-2017" : "2,3,1",
                 "Nov-2016" : "9,9,9"
               }
      },
      {
      "name" : "Valavan"
      "data" : {
                 "Jan-2017" : "1,1,1",
                 "Dec-2016" : "3,3,3",
                 "Nov-2016" : "9,9,9"
               }
      }
  </code></pre>