Mongoose: Remove object from array based on ID (Cast Error)
<p>I have a model that looks like this:</p>

<pre><code>mongoose.Schema({
  username: String,
  posts: [{ type: Schema.Types.ObjectId, ref: 'Post' }]
});
</code></pre>

<p>I have an endpoint that I want to pass an ObjectID:</p>

<pre><code>app.delete('/post', function(req, res) {
  User.findOne({ _id: req.user._id}, function(err, result) {
    result.pull({ _id: req.body.post_id });
  });
});
</code></pre>

<p>Feels like it should work, but I'm getting this error:</p>

<p><code>CastError: Cast to ObjectId failed for value "[object Object]"</code></p>

<p>What am I doing wrong?</p>