title: How do I delete a entry "object" from a mongoose user model schema
body: <p>I've figured out how to make a PUT request to store a PDF to my &quot;User&quot; schema.</p>
  <p>How would I access the <code>coverLetter</code> object from the &quot;req.profile = user&quot; to make a delete request of only this entry in this user's profile.</p>
  <p>I've only managed figured out how to delete the entire user or document from the DB.</p>
  <p>Frontend: React
  Backend: Node.js, express, MongoDB, Mongoose</p>
  <p>thanks for any suggestions</p>
  <h2>Backend</h2>
  <pre class="lang-js prettyprint-override"><code>
  // Router defintions
  router.delete(&quot;/user/documents/coverLetter/:userId&quot;, deleteData); 
  router.param(&quot;userId&quot;, userById);
  
  // Adds user to the Request object
  exports.userById = (req, res, next, id) =&gt; {
    User.findById(id).exec((err, user) =&gt; {
      if (err || !user) {
        return res.status(400).json({
          error: &quot;User not found&quot;,
        });
      }
      req.profile = user; // adds profile object in req with user info
      next();
    });
  };
  
  
  /** User Profile Object
  
  {
    coverLetter: {
      contentType: 'application/pdf',
      data: Binary {
        _bsontype: 'Binary',
        sub_type: 0,
        position: 396412,
        buffer: &lt;Buffer 25 50 44 46 2d 31 2e 33 0a 25 c4 e5 f2 e5 eb a7 f3 a0 d0 c4 c6 0a 34 20 30 20 6f 62 6a 0a 3c 3c 20 2f 4c 65 6e 67 74 68 20 35 20 30 20 52 20 2f 46 69 ... 396362 more bytes&gt;
      }
    },
    _id: 60c2ef9e13f13d902a07ab0b,
    fName: 'gh',
    lName: 'h',
    email: 'b@gmail.com',
    salt: '73bb4607-47bf-407f-9155-0b65d19c21be',
    hashed_password: 'a3e08880687ec89344e2a5c6989b1f68bcceee1b',
    created: 2021-06-11T05:07:42.472Z,
    __v: 0,
    updated: 2021-06-11T05:08:01.099Z
  }
  
  */
  
  
  /**
  * Need help with this block
  */
  exports.deleteData = (req, res) =&gt; {
      let user = req.profile
      // How do I access the coverLetter to delete it ?
  }
  
  /**
  * User Schema
  */
  const userSchema = new mongoose.Schema({
  
      fName: {
          type: String,
          trim: true,
          required: true
      },
      lName: {
          type: String,
          trim: true,
          required: true
  
      },
      coverLetter: {
          data: Buffer,
          contentType: String,
      },
  });
  
  module.exports = mongoose.model(&quot;User&quot;, userSchema);
  
  </code></pre>
  <h3>Frontend</h3>
  <pre class="lang-js prettyprint-override"><code>export const deleteCover = (userId, token) =&gt; {
      return fetch(`${process.env.REACT_APP_API_URL}/user/documents/coverLetter/${userId}`, {
          method: &quot;DELETE&quot;,
          headers: {
              Accept: &quot;application/json&quot;,
              Authorization: `Bearer ${token}`
          }
      })
          .then(response =&gt; {
              return response.json();
          })
          .catch(err =&gt; console.log(err));
  };
  
  </code></pre>