title: Delete an array element from a document with Mongoose
body: <p>I am having a schema called <strong>ReferralHistory</strong>.
  It contains  set of users and array of referred users.</p>
  <p><strong>ReferralHistory</strong></p>
  <pre><code>var mongoose = require('mongoose');
  var refferalHistorySchema = new mongoose.Schema({
      user: {
          type: mongoose.Schema.Types.ObjectId,
          ref: 'User',
          unique: true
      },
  
      referrals: [{
          type: mongoose.Schema.Types.ObjectId,
          ref: 'User'
      }],
  });
  var ReferralHistoryModel = mongoose.model('ReferralHistory', refferalHistorySchema);
  module.exports = {
      referralHistory: ReferralHistoryModel
  }
  </code></pre>
  <p>I need to delete a  particular user from referrals array  in the collection ReferralHistory[Here i only know id of referred user].How can i achieve this?</p>
  <p><strong>Edit</strong></p>
  <p><strong>Collection</strong>
  <a href="https://i.stack.imgur.com/VF2iZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VF2iZ.png" alt="enter image description here" /></a></p>
  <p>I tried</p>
  <pre><code>db.referralhistories.update({ &quot;u_referrals&quot;: &quot;593281ef966d7f0eeb94db3d&quot; }, { &quot;$pull&quot;: { &quot;u_referrals&quot;: &quot;593281ef966d7f0eeb94db3d&quot; } });
  </code></pre>
  <p><strong>O/P</strong><a href="https://i.stack.imgur.com/Runkm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Runkm.png" alt="enter image description here" /></a></p>
  <p>But document is not updating.</p>