mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-08 02:52:39 -05:00
Reverted destroy
function of CRUD plugin to chained promises
refs https://github.com/TryGhost/Team/issues/808 - see referenced issue for context, but turning this function into async-await seems to have broken error handling when deleting things that don't exist - i'm really not sure why - but my running theory is that it's something to do with Bluebird Promises vs native Promises - this should keep the same functionality until I can investigate what is going on
This commit is contained in:
parent
323074f106
commit
ce68b2e4a9
1 changed files with 6 additions and 3 deletions
|
@ -198,7 +198,7 @@ module.exports = function (Bookshelf) {
|
|||
* @param {Object} [unfilteredOptions]
|
||||
* @return {Promise<Bookshelf['Model']>} Empty Model
|
||||
*/
|
||||
destroy: async function destroy(unfilteredOptions) {
|
||||
destroy: function destroy(unfilteredOptions) {
|
||||
const options = this.filterOptions(unfilteredOptions, 'destroy');
|
||||
|
||||
if (!options.destroyBy) {
|
||||
|
@ -208,8 +208,11 @@ module.exports = function (Bookshelf) {
|
|||
}
|
||||
|
||||
// Fetch the object before destroying it, so that the changed data is available to events
|
||||
const obj = await this.forge(options.destroyBy).fetch(options);
|
||||
return obj.destroy(options);
|
||||
return this.forge(options.destroyBy)
|
||||
.fetch(options)
|
||||
.then(function then(obj) {
|
||||
return obj.destroy(options);
|
||||
});
|
||||
},
|
||||
|
||||
// When loading an instance, subclasses can specify default to fetch
|
||||
|
|
Loading…
Add table
Reference in a new issue