Replaced use of Bluebird return method from knex code

no issue

- Knex removed their use of several Bluebird methods, including `return`
- our code used `return`, but mostly to return null after a destroy action
- these uses have been replaced with `.then(() => null)` in order to
  continue returning null and to avoid breaking anything
This commit is contained in:
Daniel Lockyer 2020-04-07 07:20:56 +01:00
parent 3ebae36c0a
commit 13e1ecae27
14 changed files with 18 additions and 18 deletions

View File

@ -77,7 +77,7 @@ module.exports = {
frame.options.require = true;
return models.Invite.destroy(frame.options)
.return(null);
.then(() => null);
}
},

View File

@ -139,7 +139,7 @@ module.exports = {
},
permissions: true,
query(frame) {
return models.Label.destroy(frame.options).return(null);
return models.Label.destroy(frame.options).then(() => null);
}
}
};

View File

@ -196,7 +196,7 @@ module.exports = {
frame.options.require = true;
return models.Post.destroy(frame.options)
.return(null)
.then(() => null)
.catch(models.Post.NotFoundError, () => {
throw new common.errors.NotFoundError({
message: common.i18n.t('errors.api.pages.pageNotFound')

View File

@ -231,7 +231,7 @@ module.exports = {
frame.options.require = true;
return models.Post.destroy(frame.options)
.return(null)
.then(() => null)
.catch(models.Post.NotFoundError, () => {
throw new common.errors.NotFoundError({
message: common.i18n.t('errors.api.posts.postNotFound')

View File

@ -142,7 +142,7 @@ module.exports = {
},
permissions: true,
query(frame) {
return models.Tag.destroy(frame.options).return(null);
return models.Tag.destroy(frame.options).then(() => null);
}
}
};

View File

@ -130,11 +130,11 @@ module.exports = {
return models.Base.transaction((t) => {
frame.options.transacting = t;
return Promise.all([
models.Post.destroyByAuthor(frame.options)
]).then(() => {
return models.Post.destroyByAuthor(frame.options)
.then(() => {
return models.User.destroy(Object.assign({status: 'all'}, frame.options));
}).return(filename);
})
.then(() => filename);
}).catch((err) => {
return Promise.reject(new common.errors.NoPermissionError({
err: err

View File

@ -84,7 +84,7 @@ module.exports = {
permissions: true,
query(frame) {
frame.options.require = true;
return models.Webhook.destroy(frame.options).return(null);
return models.Webhook.destroy(frame.options).then(() => null);
}
}
};

View File

@ -77,7 +77,7 @@ module.exports = {
frame.options.require = true;
return models.Invite.destroy(frame.options)
.return(null);
.then(() => null);
}
},

View File

@ -196,7 +196,7 @@ module.exports = {
frame.options.require = true;
return models.Post.destroy(frame.options)
.return(null)
.then(() => null)
.catch(models.Post.NotFoundError, () => {
throw new common.errors.NotFoundError({
message: common.i18n.t('errors.api.pages.pageNotFound')

View File

@ -191,7 +191,7 @@ module.exports = {
frame.options.require = true;
return models.Post.destroy(frame.options)
.return(null)
.then(() => null)
.catch(models.Post.NotFoundError, () => {
throw new common.errors.NotFoundError({
message: common.i18n.t('errors.api.posts.postNotFound')

View File

@ -142,7 +142,7 @@ module.exports = {
},
permissions: true,
query(frame) {
return models.Tag.destroy(frame.options).return(null);
return models.Tag.destroy(frame.options).then(() => null);
}
}
};

View File

@ -129,7 +129,7 @@ module.exports = {
models.Post.destroyByAuthor(frame.options)
]).then(() => {
return models.User.destroy(Object.assign({status: 'all'}, frame.options));
}).return(null);
}).then(() => null);
}).catch((err) => {
return Promise.reject(new common.errors.NoPermissionError({
err: err

View File

@ -84,7 +84,7 @@ module.exports = {
permissions: true,
query(frame) {
frame.options.require = true;
return models.Webhook.destroy(frame.options).return(null);
return models.Webhook.destroy(frame.options).then(() => null);
}
}
};

View File

@ -314,7 +314,7 @@ module.exports.extendModel = function extendModel(Post, Posts, ghostBookshelf) {
return (options.transacting || ghostBookshelf.knex)('posts_authors')
.where('author_id', authorId)
.del()
.return(response);
.then(() => response);
})
.catch((err) => {
throw new common.errors.GhostError({err: err});