I want to delete one item only if it matches some condition. It would be something like this:
Session.findOne({ id:req.body.sessionId },function(err,session){
if(session.user == req.body.userId) {
session.remove();
}
});
Which obviously doesn't work. How can I achieve that?
You can test multiple conditions at the same time in Mongoose. This should work for you.