I have a model that looks like this:
mongoose.Schema({ username: String, posts: [{ type: Schema.Types.ObjectId, ref: \'Post\' }] });
I have
In order to make a research with an id in a collection you need to create a new ObjectId and then pass the id into it.
app.delete('/post', function(req, res) { User.findOne({ _id: _id: ObjectId (req.user._id)}, function(err, result) { result.pull({ _id: ObjectId (req.body.post_id) }); }); });