async updateStatusLock(Model, id, status, allowedStatuses) {
        let model;
        await Model.transaction(async (transacting) => {
            model = await Model.findOne({id}, {require: true, transacting, forUpdate: true});
            if (!allowedStatuses.includes(model.get('status'))) {
                model = undefined;
                return;
            }
            await model.save({
                status
            }, {patch: true, transacting, autoRefresh: false});
        });
        return model;
    }
@private
Update the status of an email or emailBatch to a given status, but first check if their current status is 'pending' or 'failed'.
@param {object} Model Bookshelf model constructor
@param {string} id id of the model
@param {string} status set the status of the model to this value
@param {string[]} allowedStatuses Check if the models current status is one of these values
@returns {Promise<object|undefined>} The updated model. Undefined if the model didn't pass the status check.