Skip to content

Commit

Permalink
Replaced Promise.each() with .all() in models/base/bookshelf (TryGhos…
Browse files Browse the repository at this point in the history
…t#15509)

refs: TryGhost#14882

- Removing bluebird specific methods in favour of native promises so we can remove the bluebird dependency.

Co-authored-by: Carol-Barno <cbarno@innovexsolutions.co.ke>
Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
  • Loading branch information
3 people authored Oct 13, 2022
1 parent 63f90c2 commit 5c36167
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions ghost/core/core/server/models/base/bookshelf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const _ = require('lodash');
const bookshelf = require('bookshelf');
const ObjectId = require('bson-objectid').default;
const plugins = require('@tryghost/bookshelf-plugins');
const Promise = require('bluebird');

const db = require('../../data/db');

Expand Down Expand Up @@ -84,13 +83,13 @@ ghostBookshelf.plugin('bookshelf-relations', {
return Promise.resolve();
}

return Promise.each(targets.models, function (target, index) {
return Promise.all(targets.models.map((target, index) => {
queryOptions.query.where[existing.relatedData.otherKey] = target.id;

return existing.updatePivot({
sort_order: index
}, _.extend({}, options, queryOptions));
});
}));
},
beforeRelationCreation: function onCreatingRelation(model, data) {
data.id = ObjectId().toHexString();
Expand Down

0 comments on commit 5c36167

Please sign in to comment.