title: Update name in nested object array
body: <p>I'm new to MongoDB using angular as frontend. I'm trying to update a name in nested object array.</p>
  <p>My Schema is as follows:</p>
  <pre><code>const mongoose = require(&quot;mongoose&quot;);
  
  const projectDragDropSchema = mongoose.Schema({
    _idProject: mongoose.Schema.Types.ObjectId,
    projectTitle: { type: String, required: true },
    boards: [
      {
        _idBoard: mongoose.Schema.Types.ObjectId,
        boardTitle: { type: String, required: false },
        cards: [
          {
            type: new mongoose.Schema(
              {
                cardId: { type: mongoose.Schema.Types.ObjectId, required: true },
                cardTitle: { type: String, required: false },
              }
              // { minimize: false }
            ),
            required: false,
          },
        ],
        required: false,
      },
    ],
  });
  
  module.exports = mongoose.model(&quot;ProjectDragDrop&quot;, projectDragDropSchema);
  
  </code></pre>
  <p>I'm trying to update the cardTitle.
  I have written the multiple updates to it, but unable to find the correct one.</p>
  <p>The Router:</p>
  <pre><code>router.patch(
    &quot;/updateProjectBoardCardName/:_idProject/:_id&quot;,
    projectBoardsCards.updateCardName
  );
  </code></pre>
  <p>The code:</p>
  <pre><code>exports.updateCardName = (req, res) =&gt; {
    const idProject = req.params._idProject;
    const boardID = req.params._id;
    projectDragDropSchema
      .update(
        { _idProject: idProject, &quot;boards._id&quot;: boardID },
        { cards: { $elemMatch: { _id: req.body.params } } },
        { $set: { &quot;cards.$.cardTitle&quot;: req.body.params } }
      )
      .exec()
      .then((result) =&gt; {
        console.log(result);
        res.status(200).json(result);
      })
      .catch((err) =&gt; {
        console.log(err);
        res.status(500).json({
          error: err,
        });
      });
  };
  
  </code></pre>
  <p>Thanks in advance.</p>