Mongoose ahora admite esto de forma nativa con findOneAndUpdate (llama a MongoDB findAndModify).
La opción upsert =true crea el objeto si no existe. por defecto es falso.
MyModel.findOneAndUpdate(
{foo: 'bar'}, // find a document with that filter
modelDoc, // document to insert when nothing was found
{upsert: true, new: true, runValidators: true}, // options
function (err, doc) { // callback
if (err) {
// handle error
} else {
// handle document
}
}
);