title: How to update array of key/value pairs into a mongoose?
body: <p><strong>Background:</strong> I have an array of objects sent from Vue Axios.  These objects are key value pairs which is stored in the req.body.</p>
  
  <p><strong>Req.body</strong></p>
  
  <pre><code>keyValue:  [{key:"some key", value:"some value"}, {key:"some key2", value:"some value2"}]
  </code></pre>
  
  <p><strong>Note</strong>:   I can expect to receive a req.body with a numerous amount objects withing the array. I can not access the "key" and "value" in the objects without adding a [ ] or req.body.keyValue[0]. </p>
  
  <p>How can I dynamically add each object's "key" and "value" into mongoose without having to explicitly call a specific object?</p>
  
  <p><strong>I am trying to do something like this:</strong>(failed attempt)</p>
  
  <pre><code>const mongoose = require("mongoose");
  const Schema = mongoose.Schema;
  
  const Schema = new Schema({
    Pair: [{
      Key: String,
      Value: Number
    }]
  });
  
  router.post("/",  (req, res) =&gt; {
   User.update({},
    {$push:
    {Pair:{
          Key: req.body.keyValue.key,
           Value: req.body.keyValue.value
         }
        }
      }, 
    (err,result)=&gt;{
      if(err){
        console.log(err);
        res.status(400).send('Error')
      }else{
        res.status(200).send(result);
      }
    })
  }
  
  </code></pre>
  
  <p>I hope I was able to explain well enough.  Let me know if there is any confusions. Thanks!</p>