title: Update specific index of array in MongoDB
body: <p>I would like to update the shipping property in my MongoDb (CRUD).
  Shipping is an <strong>array</strong> property that contains object[index]. How to update the specific object such as index1 or index2.</p>
  
  <p><a href="https://i.stack.imgur.com/QeQQH.png" rel="nofollow noreferrer">This show the shipping property that contains two objects</a></p>
  
  <p>If I want to update Object only at index 1 on the providerName, how can I do that</p>
  
  <pre><code>exports.updateShpping = (req, res) =&gt; {
  const {shipping} = req.body;
  Shop.findOne({ _id: req.shop._id },  (err, shop) =&gt; {
  
      if (!shipping) {
          return res.status(400).json({
              error: 'shipping is required'
          });
      } else {
          shop.shipping.push(shipping) ;
      }
  
      shop.save((err, addShipping) =&gt; {
          if (err) {
              console.log('Shipping ADD ERROR', err);
              return res.status(400).json({
                  error: 'Shipping add failed'
              });
          }
          res.json(addShipping);
      });
  });exports.updateShpping = (req, res) =&gt; {
  const {shipping} = req.body;
  Shop.findOne({ _id: req.shop._id },  (err, shop) =&gt; {
  
      if (!shipping) {
          return res.status(400).json({
              error: 'shipping is required'
          });
      } else {
          shop.shipping.push(shipping) ;
      }
  
      shop.save((err, addShipping) =&gt; {
          if (err) {
              console.log('Shipping ADD ERROR', err);
              return res.status(400).json({
                  error: 'Shipping add failed'
              });
          }
          res.json(addShipping);
      });
  });
  </code></pre>
  
  <p>};</p>