mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-23 22:11:09 +03:00
Removed explicit loading of Bookshelf registry plugin
- as per 5a5a5d162e
, the Bookshelf registry plugin is now in core
- we no longer need to explicitly load the plugin, and it displays a
warning if you do
- this change also turns `._models` into `.registry.models`, so our code has
been updated to reflect that
This commit is contained in:
parent
7a3725fdbf
commit
80fa1d903e
@ -3,7 +3,7 @@ const ghostBookshelf = require('./base');
|
||||
|
||||
const candidates = [];
|
||||
|
||||
_.each(ghostBookshelf._models, (model) => {
|
||||
_.each(ghostBookshelf.registry.models, (model) => {
|
||||
candidates.push([model, model.prototype.tableName.replace(/s$/, '')]);
|
||||
});
|
||||
|
||||
|
@ -10,9 +10,6 @@ const db = require('../../data/db');
|
||||
// Initializes a new Bookshelf instance called ghostBookshelf, for reference elsewhere in Ghost.
|
||||
const ghostBookshelf = bookshelf(db.knex);
|
||||
|
||||
// Load the Bookshelf registry plugin, which helps us avoid circular dependencies
|
||||
ghostBookshelf.plugin('registry');
|
||||
|
||||
ghostBookshelf.plugin(plugins.eagerLoad);
|
||||
|
||||
// Add committed/rollback events.
|
||||
|
@ -106,17 +106,17 @@ module.exports = function (Bookshelf) {
|
||||
|
||||
if (!withRelated) {
|
||||
return _.map(objects, (object) => {
|
||||
object = Bookshelf._models[modelName].prototype.toJSON.bind({
|
||||
object = Bookshelf.registry.models[modelName].prototype.toJSON.bind({
|
||||
attributes: object,
|
||||
related: function (key) {
|
||||
return object[key];
|
||||
},
|
||||
serialize: Bookshelf._models[modelName].prototype.serialize,
|
||||
formatsToJSON: Bookshelf._models[modelName].prototype.formatsToJSON
|
||||
serialize: Bookshelf.registry.models[modelName].prototype.serialize,
|
||||
formatsToJSON: Bookshelf.registry.models[modelName].prototype.formatsToJSON
|
||||
})();
|
||||
|
||||
object = Bookshelf._models[modelName].prototype.fixBools(object);
|
||||
object = Bookshelf._models[modelName].prototype.fixDatesWhenFetch(object);
|
||||
object = Bookshelf.registry.models[modelName].prototype.fixBools(object);
|
||||
object = Bookshelf.registry.models[modelName].prototype.fixDatesWhenFetch(object);
|
||||
return object;
|
||||
});
|
||||
}
|
||||
@ -180,7 +180,7 @@ module.exports = function (Bookshelf) {
|
||||
object[relation] = relationsToAttach[relation][object.id];
|
||||
});
|
||||
|
||||
object = Bookshelf._models[modelName].prototype.toJSON.bind({
|
||||
object = Bookshelf.registry.models[modelName].prototype.toJSON.bind({
|
||||
attributes: object,
|
||||
_originalOptions: {
|
||||
withRelated: Object.keys(relationsToAttach)
|
||||
@ -188,12 +188,12 @@ module.exports = function (Bookshelf) {
|
||||
related: function (key) {
|
||||
return object[key];
|
||||
},
|
||||
serialize: Bookshelf._models[modelName].prototype.serialize,
|
||||
formatsToJSON: Bookshelf._models[modelName].prototype.formatsToJSON
|
||||
serialize: Bookshelf.registry.models[modelName].prototype.serialize,
|
||||
formatsToJSON: Bookshelf.registry.models[modelName].prototype.formatsToJSON
|
||||
})();
|
||||
|
||||
object = Bookshelf._models[modelName].prototype.fixBools(object);
|
||||
object = Bookshelf._models[modelName].prototype.fixDatesWhenFetch(object);
|
||||
object = Bookshelf.registry.models[modelName].prototype.fixBools(object);
|
||||
object = Bookshelf.registry.models[modelName].prototype.fixDatesWhenFetch(object);
|
||||
return object;
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user