Q:

Mongoose .save() not executing

I have this piece of code that is not working. I'm trying to save a user document after modifying it with an ObjectId (by adding this to an array). However, the user.save() is never executed (I know this because the document doesn't change in the db) and neither is the callback/promise. The Voot is however being saved.
I have tried tweaking around with the callbacks and promises but it didn't work out. Does anyone know what to do?
Here is the code:
(to avoid confusion, note that the handleError() and sendJson() functions are custom functions made by me)
// Create new voot
var newVoot = Voot({
    title,
    body,
    user: userId,
    is_public,
    create_date
});
newVoot.save().then((voot) => {
    User.findById(userId, (err, user) => {
        handleError(err, 400, res);
        if (user) {
            user.voots.push(voot._id);
            // This console log shows me the correct modified user document
            console.log(user);
            user.save().then(() => {
                // This console.log and sendJson does not get executed
                console.log("User object is saved");
                sendJson(200, {voot}, res);
            }).catch((err) => {
                // This console log does not get executed
                console.log(err);
            });
        }
    })
});

A:

User.findById(userId, (err, user) => ... has two params in its callback function: err and user. 
user is the document returned from MongoDB, meaning it's a normal Javascript object and thus you can't call .save() on it.
For this use case you could use Mongoose's findbyIdAndUpdate(), which will do both of the operations you need to the User model. Just remember to give { upsert: true } as an options object to make sure you create a new document if it doesn't already exist.
Example
User.findByIdAndUpdate({ id }, { update1: 'value' }, { upsert: true }, (err, result) => {
  // handle result
})

