Waiting knex fired event before load bookshelf

This commit is contained in:
Aurélien Georget 2016-07-05 14:32:50 +02:00
parent 3734bb2f59
commit 1b7e1b9e6a
2 changed files with 8 additions and 7 deletions

View File

@ -37,16 +37,16 @@ module.exports = function (strapi) {
initialize: function (cb) {
let globalName;
// Make sure the Knex hook is present since Knex needs it.
if (!strapi.hooks.knex) {
strapi.log.error('Impossible to load the ORM without the query builder!');
strapi.log.error('You need to install the Strapi query builder with `$ npm install strapi-knex --save`.');
strapi.stop(1);
}
// Only run this logic after the Knex has finished to load.
strapi.after('hook:knex:loaded', function () {
// Make sure the Knex hook is present since Knex needs it.
if (!strapi.hooks.external.knex) {
strapi.log.error('Impossible to load the ORM without the query builder!');
strapi.log.error('You need to install the Strapi query builder with `$ npm install strapi-knex --save`.');
strapi.stop(1);
}
// Initialize collections
_.set(strapi, 'bookshelf.collections', {});

View File

@ -63,6 +63,7 @@ module.exports = function (strapi) {
cb(err);
}
}
return memo;
}, {}));