Mongoose Schema.update doesn't update boolean

Solution 1:

Turns out I just forgot to add the isAdmin field to my User Schema! Also, my call to the update was wrong, I changed it to this:

User.update({ email: targetUser.email }, { $set: { isAdmin: true }}, { $push: { 'log.updated': new Date() } }, function (err, user) {
  if (err) {
    responseObject.err = err;
    responseObject.data = null;
    responseObject.code = 422;

    return res.json(responseObject);
  }


  return res.json(responseObject);
});

Thanks to everyone that put an effort to help me! :)

Solution 2:

I encountered a similar problem. The solution was to add the callback.

This doesn't work:

Ride.updateOne({driver:req.body.id},{$set:{isBusy:true}});

This works:

Ride.updateOne({driver:req.body.id},{$set:{isBusy:true}},(e,s)=>{});