title: Mongoose pull ObjectId from array
body: <p>i'm trying to do a pretty simple operation, pull an item from an array with Mongoose on a Mongo database like so:</p>
  
  <pre><code>User.update({ _id: fromUserId }, { $pull: { linkedUsers: [idToDelete] } });
  </code></pre>
  
  <p><code>fromUserId</code> &amp; <code>idToDelete</code> are both Objects Ids. </p>
  
  <p>The schema for Users goes like this:</p>
  
  <pre><code>var UserSchema = new Schema({
    groups: [],
    linkedUsers: [],
    name: { type: String, required: true, index: { unique: true } }
  });
  </code></pre>
  
  <p><code>linkedUsers</code> is an array that only receives Ids of other users.</p>
  
  <p>I've tried this as well:</p>
  
  <pre><code>User.findOne({ _id: fromUserId }, function(err, user) {
    user.linkedUsers.pull(idToDelete);
    user.save();
  });
  </code></pre>
  
  <p>But with no luck. </p>
  
  <p>The second option seem to almost work when i console the lenghts of the array at different positions but after calling <code>save</code> and checking, the length is still at 36:</p>
  
  <pre><code> User.findOne({ _id: fromUserId }, function(err, user) {
      console.log(user.linkedUsers.length); // returns 36
      user.linkedUsers.pull(idToDelete);
      console.log(user.linkedUsers.length); // returns 35
      user.save();
    });
  </code></pre>
  
  <p>So it looks like i'm close but still, no luck. Both Ids are sent via the frontend side of the app.
  I'm running those versions:</p>
  
  <pre><code>"mongodb": "^2.2.29",
  "mongoose": "^5.0.7",
  </code></pre>
  
  <p>Thanks in advance.</p>